From aa0888715e58f79c3be05467cc39149b624a63d2 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Tue, 11 Nov 2025 04:05:53 +0000 Subject: [PATCH 1/4] Configurations: 'specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/tspconfig.yaml', API Version: 2025-06-01-preview, SDK Release Type: beta, and CommitSHA: '1d3ac611f503e05650fb85520582b06140d2599e' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=5556695 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- .../CHANGELOG.md | 71 + .../_metadata.json | 13 +- .../apiview-properties.json | 513 +- .../mgmt/mysqlflexibleservers/__init__.py | 4 +- ...my_sql_management_client.py => _client.py} | 151 +- .../mysqlflexibleservers/_configuration.py | 15 +- .../mysqlflexibleservers/_utils/__init__.py | 2 +- .../mysqlflexibleservers/_utils/model_base.py | 1237 ++ .../_utils/serialization.py | 2 +- .../mgmt/mysqlflexibleservers/_validation.py | 66 + .../mgmt/mysqlflexibleservers/_version.py | 2 +- .../mgmt/mysqlflexibleservers/aio/__init__.py | 4 +- ...my_sql_management_client.py => _client.py} | 151 +- .../aio/_configuration.py | 15 +- .../aio/operations/__init__.py | 75 +- ...d_threat_protection_settings_operations.py | 678 - .../_azure_ad_administrators_operations.py | 575 - .../_backup_and_export_operations.py | 327 - .../aio/operations/_backups_operations.py | 272 - .../_check_name_availability_operations.py | 177 - ...vailability_without_location_operations.py | 161 - ...virtual_network_subnet_usage_operations.py | 171 - .../operations/_configurations_operations.py | 884 -- .../aio/operations/_databases_operations.py | 557 - .../operations/_firewall_rules_operations.py | 560 - ..._get_private_dns_zone_suffix_operations.py | 104 - ..._location_based_capabilities_operations.py | 138 - ...ocation_based_capability_set_operations.py | 196 - .../aio/operations/_log_files_operations.py | 143 - .../_long_running_backup_operations.py | 287 - .../_long_running_backups_operations.py | 208 - .../operations/_maintenances_operations.py | 433 - .../_operation_progress_operations.py | 113 - .../_operation_results_operations.py | 113 - .../aio/operations/_operations.py | 9408 ++++++++++++- ...private_endpoint_connections_operations.py | 536 - .../_private_link_resources_operations.py | 178 - .../aio/operations/_replicas_operations.py | 142 - .../_servers_migration_operations.py | 182 - .../aio/operations/_servers_operations.py | 1903 --- .../mysqlflexibleservers/models/__init__.py | 72 +- ...l_management_client_enums.py => _enums.py} | 35 +- .../mysqlflexibleservers/models/_models.py | 4289 ++++++ .../models/_models_py3.py | 4048 ------ .../operations/__init__.py | 75 +- ...d_threat_protection_settings_operations.py | 840 -- .../_azure_ad_administrators_operations.py | 730 - .../_backup_and_export_operations.py | 403 - .../operations/_backups_operations.py | 376 - .../_check_name_availability_operations.py | 210 - ...vailability_without_location_operations.py | 192 - ...virtual_network_subnet_usage_operations.py | 205 - .../operations/_configurations_operations.py | 1075 -- .../operations/_databases_operations.py | 694 - .../operations/_firewall_rules_operations.py | 705 - ..._get_private_dns_zone_suffix_operations.py | 125 - ..._location_based_capabilities_operations.py | 168 - ...ocation_based_capability_set_operations.py | 258 - .../operations/_log_files_operations.py | 178 - .../_long_running_backup_operations.py | 325 - .../_long_running_backups_operations.py | 276 - .../operations/_maintenances_operations.py | 542 - .../_operation_progress_operations.py | 145 - .../_operation_results_operations.py | 145 - .../operations/_operations.py | 11178 +++++++++++++++- ...private_endpoint_connections_operations.py | 697 - .../_private_link_resources_operations.py | 252 - .../operations/_replicas_operations.py | 178 - .../_servers_migration_operations.py | 216 - .../operations/_servers_operations.py | 2327 ---- ...advanced_threat_protection_settings_get.py | 7 +- ...dvanced_threat_protection_settings_list.py | 7 +- ...reat_protection_settings_patch_disabled.py | 7 +- ...hreat_protection_settings_patch_enabled.py | 7 +- ...threat_protection_settings_put_disabled.py | 7 +- ..._threat_protection_settings_put_enabled.py | 7 +- .../azure_ad_administrator_create.py | 6 +- .../azure_ad_administrator_delete.py | 7 +- .../azure_ad_administrator_get.py | 7 +- .../azure_ad_administrators_list_by_server.py | 7 +- .../generated_samples/backup_and_export.py | 7 +- .../generated_samples/backup_get.py | 7 +- .../generated_samples/backup_put.py | 7 +- .../backups_list_by_server.py | 7 +- .../capabilities_by_location_list.py | 7 +- .../capability_set_by_location.py | 8 +- .../capability_set_list_by_location.py | 7 +- .../check_name_availability.py | 7 +- ...heck_name_availability_without_location.py | 7 +- .../check_virtual_network_subnet_usage.py | 6 +- .../configuration_create_or_update.py | 7 +- .../generated_samples/configuration_get.py | 7 +- .../generated_samples/configuration_update.py | 7 +- .../configurations_batch_update.py | 7 +- .../configurations_list_by_server.py | 7 +- .../generated_samples/cutover_migration.py | 7 +- .../generated_samples/database_create.py | 7 +- .../generated_samples/database_delete.py | 7 +- .../generated_samples/database_get.py | 7 +- .../databases_list_by_server.py | 7 +- .../generated_samples/firewall_rule_create.py | 7 +- .../generated_samples/firewall_rule_delete.py | 7 +- .../generated_samples/firewall_rule_get.py | 7 +- .../firewall_rules_list_by_server.py | 7 +- .../get_private_dns_zone_suffix.py | 5 +- .../log_files_list_by_server.py | 7 +- .../generated_samples/long_running_backup.py | 7 +- .../long_running_backup_delete.py | 42 + .../long_running_backup_get.py | 7 +- .../long_running_backups_list_by_server.py | 7 +- ...ance_policy_patch_opt_in_virtual_canary.py | 7 +- ...nce_policy_patch_opt_out_virtual_canary.py | 7 +- .../generated_samples/maintenance_read.py | 7 +- .../generated_samples/maintenance_update.py | 7 +- .../maintenances_list_by_server.py | 7 +- ...peration_progress_get_backup_and_export.py | 7 +- ...ration_progress_get_import_from_storage.py | 7 +- .../operation_results_get.py | 7 +- .../generated_samples/operations_list.py | 5 +- .../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 | 10 +- .../replicas_list_by_server.py | 7 +- .../generated_samples/server_create.py | 7 +- .../server_create_replica.py | 6 +- .../server_create_with_byok.py | 6 +- .../server_create_with_database_port.py | 7 +- ...rver_create_with_lower_case_table_names.py | 68 + ...erver_create_with_point_in_time_restore.py | 6 +- .../generated_samples/server_delete.py | 7 +- .../generated_samples/server_detach_vnet.py | 7 +- .../generated_samples/server_failover.py | 7 +- .../generated_samples/server_get.py | 7 +- .../generated_samples/server_get_with_vnet.py | 7 +- .../generated_samples/server_reset_gtid.py | 7 +- .../generated_samples/server_restart.py | 7 +- .../generated_samples/server_start.py | 7 +- .../generated_samples/server_stop.py | 7 +- .../generated_samples/server_update.py | 7 +- .../server_update_with_byok.py | 6 +- ...update_with_customer_maintenance_window.py | 7 +- ...ver_validate_estimate_high_availability.py | 7 +- .../generated_samples/servers_list.py | 7 +- .../servers_list_by_resource_group.py | 7 +- .../generated_samples/validate_backup.py | 7 +- .../generated_tests/conftest.py | 2 +- ...d_threat_protection_settings_operations.py | 34 +- ...at_protection_settings_operations_async.py | 34 +- ...ment_azure_ad_administrators_operations.py | 40 +- ...zure_ad_administrators_operations_async.py | 40 +- ...management_backup_and_export_operations.py | 4 +- ...ment_backup_and_export_operations_async.py | 4 +- ...st_my_sql_management_backups_operations.py | 23 +- ...sql_management_backups_operations_async.py | 23 +- ...ment_check_name_availability_operations.py | 3 +- ...heck_name_availability_operations_async.py | 3 +- ...vailability_without_location_operations.py | 3 +- ...ility_without_location_operations_async.py | 3 +- ...virtual_network_subnet_usage_operations.py | 3 +- ...l_network_subnet_usage_operations_async.py | 3 +- ...ql_management_configurations_operations.py | 82 +- ...agement_configurations_operations_async.py | 82 +- ..._my_sql_management_databases_operations.py | 31 +- ...l_management_databases_operations_async.py | 31 +- ...ql_management_firewall_rules_operations.py | 31 +- ...agement_firewall_rules_operations_async.py | 31 +- ..._get_private_dns_zone_suffix_operations.py | 6 +- ...rivate_dns_zone_suffix_operations_async.py | 6 +- ..._location_based_capabilities_operations.py | 3 +- ...ion_based_capabilities_operations_async.py | 3 +- ...ocation_based_capability_set_operations.py | 18 +- ...n_based_capability_set_operations_async.py | 18 +- ..._my_sql_management_log_files_operations.py | 3 +- ...l_management_log_files_operations_async.py | 3 +- ...nagement_long_running_backup_operations.py | 15 +- ...nt_long_running_backup_operations_async.py | 17 +- ...agement_long_running_backups_operations.py | 18 +- ...t_long_running_backups_operations_async.py | 18 +- ..._sql_management_maintenances_operations.py | 27 +- ...anagement_maintenances_operations_async.py | 27 +- ...anagement_operation_progress_operations.py | 3 +- ...ent_operation_progress_operations_async.py | 3 +- ...management_operation_results_operations.py | 3 +- ...ment_operation_results_operations_async.py | 3 +- .../test_my_sql_management_operations.py | 6 +- ...test_my_sql_management_operations_async.py | 6 +- ...private_endpoint_connections_operations.py | 42 +- ...e_endpoint_connections_operations_async.py | 44 +- ...ement_private_link_resources_operations.py | 16 +- ...private_link_resources_operations_async.py | 16 +- ...t_my_sql_management_replicas_operations.py | 3 +- ...ql_management_replicas_operations_async.py | 3 +- ...management_servers_migration_operations.py | 3 +- ...ment_servers_migration_operations_async.py | 3 +- ...st_my_sql_management_servers_operations.py | 333 +- ...sql_management_servers_operations_async.py | 351 +- .../pyproject.toml | 6 +- .../tsp-location.yaml | 4 + 201 files changed, 27882 insertions(+), 26022 deletions(-) rename sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/{_my_sql_management_client.py => _client.py} (93%) create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_validation.py rename sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/{_my_sql_management_client.py => _client.py} (94%) delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py rename sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/{_my_sql_management_client_enums.py => _enums.py} (88%) create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_link_resources_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md index eeb74c271424..7508e1d0e116 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md @@ -1,5 +1,76 @@ # Release History +## 1.0.0b4 (2025-11-11) + +### Features Added + + - Model `MySQLManagementClient` added parameter `cloud_setting` in method `__init__` + - Client `MySQLManagementClient` added method `send_request` + - Client `MySQLManagementClient` added operation group `private_endpoint_connections` + - Client `MySQLManagementClient` added operation group `private_link_resources` + - Model `AzureADAdministrator` added property `properties` + - Model `Capability` added property `properties` + - Model `HighAvailability` added property `replication_mode` + - Model `MaintenanceWindow` added property `batch_of_maintenance` + - Model `OperationProgressResult` added property `properties` + - Model `ServerBackupV2` added property `properties` + - Model `ServerForUpdate` added property `properties` + - Enum `ServerVersion` added member `ENUM_8_4` + - Added model `AdministratorProperties` + - Added model `AdvancedThreatProtectionUpdateProperties` + - Added enum `BatchOfMaintenance` + - Added model `CapabilityPropertiesV2` + - Added model `MaintenancePropertiesForUpdate` + - Added enum `Origin` + - Added model `PrivateEndpointConnectionListResult` + - Added model `PrivateLinkResource` + - Added model `PrivateLinkResourceProperties` + - Added enum `ReplicationMode` + - Added model `ServerBackupPropertiesV2` + - Added model `ServerPropertiesForUpdate` + - Added model `ValidateBackupResponseProperties` + - Model `LongRunningBackupOperations` added method `begin_delete` + - Added model `PrivateEndpointConnectionsOperations` + - Added model `PrivateLinkResourcesOperations` + +### Breaking Changes + + - Model `AdvancedThreatProtectionForUpdate` deleted or renamed its instance variable `state` + - Model `AzureADAdministrator` deleted or renamed its instance variable `administrator_type` + - Model `AzureADAdministrator` deleted or renamed its instance variable `login` + - Model `AzureADAdministrator` deleted or renamed its instance variable `sid` + - Model `AzureADAdministrator` deleted or renamed its instance variable `tenant_id` + - Model `AzureADAdministrator` deleted or renamed its instance variable `identity_resource_id` + - Model `Capability` deleted or renamed its instance variable `supported_geo_backup_regions` + - Model `Capability` deleted or renamed its instance variable `supported_flexible_server_editions` + - Model `Capability` deleted or renamed its instance variable `supported_server_versions` + - Model `Capability` deleted or renamed its instance variable `supported_features` + - Model `MaintenanceUpdate` deleted or renamed its instance variable `maintenance_start_time` + - Model `OperationProgressResult` deleted or renamed its instance variable `object_type` + - Model `ServerBackupV2` deleted or renamed its instance variable `backup_name_v2` + - Model `ServerBackupV2` deleted or renamed its instance variable `backup_type` + - Model `ServerBackupV2` deleted or renamed its instance variable `completed_time` + - Model `ServerBackupV2` deleted or renamed its instance variable `source` + - Model `ServerBackupV2` deleted or renamed its instance variable `provisioning_state` + - Model `ServerForUpdate` deleted or renamed its instance variable `administrator_login_password` + - Model `ServerForUpdate` deleted or renamed its instance variable `version` + - Model `ServerForUpdate` deleted or renamed its instance variable `storage` + - Model `ServerForUpdate` deleted or renamed its instance variable `backup` + - Model `ServerForUpdate` deleted or renamed its instance variable `high_availability` + - Model `ServerForUpdate` deleted or renamed its instance variable `maintenance_policy` + - Model `ServerForUpdate` deleted or renamed its instance variable `maintenance_window` + - Model `ServerForUpdate` deleted or renamed its instance variable `replication_role` + - Model `ServerForUpdate` deleted or renamed its instance variable `data_encryption` + - Model `ServerForUpdate` deleted or renamed its instance variable `network` + - Model `ValidateBackupResponse` deleted or renamed its instance variable `number_of_containers` + - Deleted or renamed model `CapabilitySetsList` + - Deleted or renamed model `Provisioning` + - Method `ConfigurationsOperations.list_by_server` changed its parameter `tags` from `positional_or_keyword` to `keyword_only` + - Method `ConfigurationsOperations.list_by_server` changed its parameter `keyword` from `positional_or_keyword` to `keyword_only` + - Method `ConfigurationsOperations.list_by_server` changed its parameter `page` from `positional_or_keyword` to `keyword_only` + - Method `ConfigurationsOperations.list_by_server` changed its parameter `page_size` from `positional_or_keyword` to `keyword_only` + - Method `LocationBasedCapabilitySetOperations.get` removed default value `None` from its parameter `capability_set_name` + ## 1.0.0 (2025-11-07) ### Features Added diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json index d7ab301dfe56..e2613d87ba4d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json @@ -1,14 +1,7 @@ { - "apiVersion": "2024-12-30", - "commit": "7931e3df0b3a23b5b32db9ce3fed184de841680b", + "apiVersion": "2025-06-01-preview", + "commit": "1d3ac611f503e05650fb85520582b06140d2599e", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers", - "emitterVersion": "0.53.1", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.42.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/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.42.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/readme.md" + "emitterVersion": "0.53.1" } \ No newline at end of file diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json index 07f52d58df6f..90a7507d6ffd 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json @@ -1,256 +1,265 @@ { - "CrossLanguagePackageId": null, + "CrossLanguagePackageId": "Microsoft.DBforMySQL", "CrossLanguageDefinitionId": { - "azure.mgmt.mysqlflexibleservers.models.AdministratorListResult": null, - "azure.mgmt.mysqlflexibleservers.models.Resource": null, - "azure.mgmt.mysqlflexibleservers.models.ProxyResource": null, - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection": null, - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate": null, - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionListResult": null, - "azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator": null, - "azure.mgmt.mysqlflexibleservers.models.Backup": null, - "azure.mgmt.mysqlflexibleservers.models.BackupRequestBase": null, - "azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest": null, - "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse": null, - "azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType": null, - "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseType": null, - "azure.mgmt.mysqlflexibleservers.models.BackupSettings": null, - "azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails": null, - "azure.mgmt.mysqlflexibleservers.models.CapabilitiesListResult": null, - "azure.mgmt.mysqlflexibleservers.models.Capability": null, - "azure.mgmt.mysqlflexibleservers.models.CapabilityProperties": null, - "azure.mgmt.mysqlflexibleservers.models.CapabilitySetsList": null, - "azure.mgmt.mysqlflexibleservers.models.Configuration": null, - "azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate": null, - "azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate": null, - "azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult": null, - "azure.mgmt.mysqlflexibleservers.models.Database": null, - "azure.mgmt.mysqlflexibleservers.models.DatabaseListResult": null, - "azure.mgmt.mysqlflexibleservers.models.DataEncryption": null, - "azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage": null, - "azure.mgmt.mysqlflexibleservers.models.ErrorAdditionalInfo": null, - "azure.mgmt.mysqlflexibleservers.models.ErrorDetail": null, - "azure.mgmt.mysqlflexibleservers.models.ErrorResponse": null, - "azure.mgmt.mysqlflexibleservers.models.FeatureProperty": null, - "azure.mgmt.mysqlflexibleservers.models.FirewallRule": null, - "azure.mgmt.mysqlflexibleservers.models.FirewallRuleListResult": null, - "azure.mgmt.mysqlflexibleservers.models.FullBackupStoreDetails": null, - "azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse": null, - "azure.mgmt.mysqlflexibleservers.models.HighAvailability": null, - "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation": null, - "azure.mgmt.mysqlflexibleservers.models.ImportFromStorageResponseType": null, - "azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties": null, - "azure.mgmt.mysqlflexibleservers.models.LogFile": null, - "azure.mgmt.mysqlflexibleservers.models.LogFileListResult": null, - "azure.mgmt.mysqlflexibleservers.models.Maintenance": null, - "azure.mgmt.mysqlflexibleservers.models.MaintenanceListResult": null, - "azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy": null, - "azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate": null, - "azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow": null, - "azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity": null, - "azure.mgmt.mysqlflexibleservers.models.MySQLServerSku": null, - "azure.mgmt.mysqlflexibleservers.models.NameAvailability": null, - "azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest": null, - "azure.mgmt.mysqlflexibleservers.models.Network": null, - "azure.mgmt.mysqlflexibleservers.models.Operation": null, - "azure.mgmt.mysqlflexibleservers.models.OperationDisplay": null, - "azure.mgmt.mysqlflexibleservers.models.OperationListResult": null, - "azure.mgmt.mysqlflexibleservers.models.OperationStatusResult": null, - "azure.mgmt.mysqlflexibleservers.models.OperationProgressResult": null, - "azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceListResult": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState": null, - "azure.mgmt.mysqlflexibleservers.models.TrackedResource": null, - "azure.mgmt.mysqlflexibleservers.models.Server": null, - "azure.mgmt.mysqlflexibleservers.models.ServerBackup": null, - "azure.mgmt.mysqlflexibleservers.models.ServerBackupListResult": null, - "azure.mgmt.mysqlflexibleservers.models.ServerBackupV2": null, - "azure.mgmt.mysqlflexibleservers.models.ServerBackupV2ListResult": null, - "azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter": null, - "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability": null, - "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2": null, - "azure.mgmt.mysqlflexibleservers.models.ServerForUpdate": null, - "azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter": null, - "azure.mgmt.mysqlflexibleservers.models.ServerListResult": null, - "azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter": null, - "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability": null, - "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2": null, - "azure.mgmt.mysqlflexibleservers.models.SkuCapability": null, - "azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2": null, - "azure.mgmt.mysqlflexibleservers.models.Storage": null, - "azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability": null, - "azure.mgmt.mysqlflexibleservers.models.SystemData": null, - "azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity": null, - "azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse": null, - "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter": null, - "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult": null, - "azure.mgmt.mysqlflexibleservers.models.Origin": null, - "azure.mgmt.mysqlflexibleservers.models.CreatedByType": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus": null, - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState": null, - "azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType": null, - "azure.mgmt.mysqlflexibleservers.models.ServerSkuTier": null, - "azure.mgmt.mysqlflexibleservers.models.ServerVersion": null, - "azure.mgmt.mysqlflexibleservers.models.CreateMode": null, - "azure.mgmt.mysqlflexibleservers.models.ReplicationRole": null, - "azure.mgmt.mysqlflexibleservers.models.DataEncryptionType": null, - "azure.mgmt.mysqlflexibleservers.models.ServerState": null, - "azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum": null, - "azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum": null, - "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode": null, - "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState": null, - "azure.mgmt.mysqlflexibleservers.models.PatchStrategy": null, - "azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance": null, - "azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType": null, - "azure.mgmt.mysqlflexibleservers.models.AdministratorType": null, - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState": null, - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState": null, - "azure.mgmt.mysqlflexibleservers.models.BackupType": null, - "azure.mgmt.mysqlflexibleservers.models.ProvisioningState": null, - "azure.mgmt.mysqlflexibleservers.models.ConfigurationSource": null, - "azure.mgmt.mysqlflexibleservers.models.IsReadOnly": null, - "azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart": null, - "azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig": null, - "azure.mgmt.mysqlflexibleservers.models.MaintenanceType": null, - "azure.mgmt.mysqlflexibleservers.models.MaintenanceState": null, - "azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState": null, - "azure.mgmt.mysqlflexibleservers.models.ObjectType": null, - "azure.mgmt.mysqlflexibleservers.models.AdministratorName": null, - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionName": null, - "azure.mgmt.mysqlflexibleservers.models.BackupFormat": null, - "azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault": null, - "azure.mgmt.mysqlflexibleservers.models.OperationStatus": null, - "azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.operations.Operations.list": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.Operations.list": null, - "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list_by_resource_group": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list_by_resource_group": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_create": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_create": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_detach_v_net": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_detach_v_net": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_failover": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_failover": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_reset_gtid": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_reset_gtid": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_restart": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_restart": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_start": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_start": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_stop": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_stop": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.validate_estimate_high_availability": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.validate_estimate_high_availability": null, - "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations.list": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations.list": null, - "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.list": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.list": null, - "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations.execute": null, - "azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.list": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.list": null, - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": null, - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.begin_create": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.begin_create": null, - "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.validate_backup": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.validate_backup": null, - "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.put": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.put": null, - "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.list": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.list": null, - "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations.begin_create": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupOperations.begin_create": null, - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_batch_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_batch_update": null, - "azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations.begin_cutover_migration": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations.begin_cutover_migration": null, - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.list": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.list": null, - "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.read": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.read": null, - "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.begin_update": null, - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.get": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.get": null, - "azure.mgmt.mysqlflexibleservers.operations.ReplicasOperations.list_by_server": null, - "azure.mgmt.mysqlflexibleservers.aio.operations.ReplicasOperations.list_by_server": null + "azure.mgmt.mysqlflexibleservers.models.AdministratorProperties": "Microsoft.DBforMySQL.AdministratorProperties", + "azure.mgmt.mysqlflexibleservers.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.mysqlflexibleservers.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection": "Microsoft.DBforMySQL.AdvancedThreatProtection", + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate": "Microsoft.DBforMySQL.AdvancedThreatProtectionForUpdate", + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProperties": "Microsoft.DBforMySQL.AdvancedThreatProtectionProperties", + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionUpdateProperties": "Microsoft.DBforMySQL.AdvancedThreatProtectionUpdateProperties", + "azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator": "Microsoft.DBforMySQL.AzureADAdministrator", + "azure.mgmt.mysqlflexibleservers.models.Backup": "Microsoft.DBforMySQL.Backup", + "azure.mgmt.mysqlflexibleservers.models.BackupRequestBase": "Microsoft.DBforMySQL.BackupRequestBase", + "azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest": "Microsoft.DBforMySQL.BackupAndExportRequest", + "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse": "Microsoft.DBforMySQL.BackupAndExportResponse", + "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseProperties": "Microsoft.DBforMySQL.BackupAndExportResponseProperties", + "azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType": "Microsoft.DBforMySQL.OperationProgressResponseType", + "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseType": "Microsoft.DBforMySQL.BackupAndExportResponseType", + "azure.mgmt.mysqlflexibleservers.models.BackupSettings": "Microsoft.DBforMySQL.BackupSettings", + "azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails": "Microsoft.DBforMySQL.BackupStoreDetails", + "azure.mgmt.mysqlflexibleservers.models.Capability": "Microsoft.DBforMySQL.Capability", + "azure.mgmt.mysqlflexibleservers.models.CapabilityProperties": "Microsoft.DBforMySQL.CapabilityProperties", + "azure.mgmt.mysqlflexibleservers.models.CapabilityPropertiesV2": "Microsoft.DBforMySQL.CapabilityPropertiesV2", + "azure.mgmt.mysqlflexibleservers.models.Configuration": "Microsoft.DBforMySQL.Configuration", + "azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate": "Microsoft.DBforMySQL.ConfigurationForBatchUpdate", + "azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdateProperties": "Microsoft.DBforMySQL.ConfigurationForBatchUpdateProperties", + "azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate": "Microsoft.DBforMySQL.ConfigurationListForBatchUpdate", + "azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult": "Microsoft.DBforMySQL.ConfigurationListResult", + "azure.mgmt.mysqlflexibleservers.models.ConfigurationProperties": "Microsoft.DBforMySQL.ConfigurationProperties", + "azure.mgmt.mysqlflexibleservers.models.Database": "Microsoft.DBforMySQL.Database", + "azure.mgmt.mysqlflexibleservers.models.DatabaseProperties": "Microsoft.DBforMySQL.DatabaseProperties", + "azure.mgmt.mysqlflexibleservers.models.DataEncryption": "Microsoft.DBforMySQL.DataEncryption", + "azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage": "Microsoft.DBforMySQL.DelegatedSubnetUsage", + "azure.mgmt.mysqlflexibleservers.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.mysqlflexibleservers.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.mysqlflexibleservers.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.mysqlflexibleservers.models.FeatureProperty": "Microsoft.DBforMySQL.FeatureProperty", + "azure.mgmt.mysqlflexibleservers.models.FirewallRule": "Microsoft.DBforMySQL.FirewallRule", + "azure.mgmt.mysqlflexibleservers.models.FirewallRuleProperties": "Microsoft.DBforMySQL.FirewallRuleProperties", + "azure.mgmt.mysqlflexibleservers.models.FullBackupStoreDetails": "Microsoft.DBforMySQL.FullBackupStoreDetails", + "azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse": "Microsoft.DBforMySQL.GetPrivateDnsZoneSuffixResponse", + "azure.mgmt.mysqlflexibleservers.models.HighAvailability": "Microsoft.DBforMySQL.HighAvailability", + "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation": "Microsoft.DBforMySQL.HighAvailabilityValidationEstimation", + "azure.mgmt.mysqlflexibleservers.models.ImportFromStorageResponseType": "Microsoft.DBforMySQL.ImportFromStorageResponseType", + "azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties": "Microsoft.DBforMySQL.ImportSourceProperties", + "azure.mgmt.mysqlflexibleservers.models.LogFile": "Microsoft.DBforMySQL.LogFile", + "azure.mgmt.mysqlflexibleservers.models.LogFileProperties": "Microsoft.DBforMySQL.LogFileProperties", + "azure.mgmt.mysqlflexibleservers.models.Maintenance": "Microsoft.DBforMySQL.Maintenance", + "azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy": "Microsoft.DBforMySQL.MaintenancePolicy", + "azure.mgmt.mysqlflexibleservers.models.MaintenanceProperties": "Microsoft.DBforMySQL.MaintenanceProperties", + "azure.mgmt.mysqlflexibleservers.models.MaintenancePropertiesForUpdate": "Microsoft.DBforMySQL.MaintenancePropertiesForUpdate", + "azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate": "Microsoft.DBforMySQL.MaintenanceUpdate", + "azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow": "Microsoft.DBforMySQL.MaintenanceWindow", + "azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity": "Microsoft.DBforMySQL.MySQLServerIdentity", + "azure.mgmt.mysqlflexibleservers.models.MySQLServerSku": "Microsoft.DBforMySQL.MySQLServerSku", + "azure.mgmt.mysqlflexibleservers.models.NameAvailability": "Microsoft.DBforMySQL.NameAvailability", + "azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest": "Microsoft.DBforMySQL.NameAvailabilityRequest", + "azure.mgmt.mysqlflexibleservers.models.Network": "Microsoft.DBforMySQL.Network", + "azure.mgmt.mysqlflexibleservers.models.Operation": "Microsoft.DBforMySQL.Operation", + "azure.mgmt.mysqlflexibleservers.models.OperationDisplay": "Microsoft.DBforMySQL.OperationDisplay", + "azure.mgmt.mysqlflexibleservers.models.OperationStatusResult": "Azure.ResourceManager.CommonTypes.OperationStatusResult", + "azure.mgmt.mysqlflexibleservers.models.OperationProgressResult": "Microsoft.DBforMySQL.OperationProgressResult", + "azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult": "Microsoft.DBforMySQL.OperationStatusExtendedResult", + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint": "Azure.ResourceManager.CommonTypes.PrivateEndpoint", + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection": "Microsoft.DBforMySQL.PrivateEndpointConnection", + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult": "Azure.ResourceManager.ResourceListResult", + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProperties": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties", + "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource": "Azure.ResourceManager.CommonTypes.PrivateLinkResource", + "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceProperties": "Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties", + "azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState": "Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState", + "azure.mgmt.mysqlflexibleservers.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.mysqlflexibleservers.models.Server": "Microsoft.DBforMySQL.Server", + "azure.mgmt.mysqlflexibleservers.models.ServerBackup": "Microsoft.DBforMySQL.ServerBackup", + "azure.mgmt.mysqlflexibleservers.models.ServerBackupProperties": "Microsoft.DBforMySQL.ServerBackupProperties", + "azure.mgmt.mysqlflexibleservers.models.ServerBackupPropertiesV2": "Microsoft.DBforMySQL.ServerBackupPropertiesV2", + "azure.mgmt.mysqlflexibleservers.models.ServerBackupV2": "Microsoft.DBforMySQL.ServerBackupV2", + "azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter": "Microsoft.DBforMySQL.ServerDetachVNetParameter", + "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability": "Microsoft.DBforMySQL.ServerEditionCapability", + "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2": "Microsoft.DBforMySQL.ServerEditionCapabilityV2", + "azure.mgmt.mysqlflexibleservers.models.ServerForUpdate": "Microsoft.DBforMySQL.ServerForUpdate", + "azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter": "Microsoft.DBforMySQL.ServerGtidSetParameter", + "azure.mgmt.mysqlflexibleservers.models.ServerProperties": "Microsoft.DBforMySQL.ServerProperties", + "azure.mgmt.mysqlflexibleservers.models.ServerPropertiesForUpdate": "Microsoft.DBforMySQL.ServerPropertiesForUpdate", + "azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter": "Microsoft.DBforMySQL.ServerRestartParameter", + "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability": "Microsoft.DBforMySQL.ServerVersionCapability", + "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2": "Microsoft.DBforMySQL.ServerVersionCapabilityV2", + "azure.mgmt.mysqlflexibleservers.models.SkuCapability": "Microsoft.DBforMySQL.SkuCapability", + "azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2": "Microsoft.DBforMySQL.SkuCapabilityV2", + "azure.mgmt.mysqlflexibleservers.models.Storage": "Microsoft.DBforMySQL.Storage", + "azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability": "Microsoft.DBforMySQL.StorageEditionCapability", + "azure.mgmt.mysqlflexibleservers.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity": "Microsoft.DBforMySQL.UserAssignedIdentity", + "azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse": "Microsoft.DBforMySQL.ValidateBackupResponse", + "azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponseProperties": "Microsoft.DBforMySQL.ValidateBackupResponseProperties", + "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter": "Microsoft.DBforMySQL.VirtualNetworkSubnetUsageParameter", + "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult": "Microsoft.DBforMySQL.VirtualNetworkSubnetUsageResult", + "azure.mgmt.mysqlflexibleservers.models.Origin": "Microsoft.DBforMySQL.Origin", + "azure.mgmt.mysqlflexibleservers.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.mysqlflexibleservers.models.AdministratorType": "Microsoft.DBforMySQL.AdministratorType", + "azure.mgmt.mysqlflexibleservers.models.AdministratorName": "Microsoft.DBforMySQL.AdministratorName", + "azure.mgmt.mysqlflexibleservers.models.ServerVersion": "Microsoft.DBforMySQL.ServerVersion", + "azure.mgmt.mysqlflexibleservers.models.CreateMode": "Microsoft.DBforMySQL.CreateMode", + "azure.mgmt.mysqlflexibleservers.models.ReplicationRole": "Microsoft.DBforMySQL.ReplicationRole", + "azure.mgmt.mysqlflexibleservers.models.DataEncryptionType": "Microsoft.DBforMySQL.DataEncryptionType", + "azure.mgmt.mysqlflexibleservers.models.ServerState": "Microsoft.DBforMySQL.ServerState", + "azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum": "Microsoft.DBforMySQL.EnableStatusEnum", + "azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum": "Microsoft.DBforMySQL.StorageRedundancyEnum", + "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode": "Microsoft.DBforMySQL.HighAvailabilityMode", + "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState": "Microsoft.DBforMySQL.HighAvailabilityState", + "azure.mgmt.mysqlflexibleservers.models.ReplicationMode": "Microsoft.DBforMySQL.replicationMode", + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus": "Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState", + "azure.mgmt.mysqlflexibleservers.models.PatchStrategy": "Microsoft.DBforMySQL.PatchStrategy", + "azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance": "Microsoft.DBforMySQL.BatchOfMaintenance", + "azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType": "Microsoft.DBforMySQL.ImportSourceStorageType", + "azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType": "Microsoft.DBforMySQL.ManagedServiceIdentityType", + "azure.mgmt.mysqlflexibleservers.models.ServerSkuTier": "Microsoft.DBforMySQL.ServerSkuTier", + "azure.mgmt.mysqlflexibleservers.models.OperationStatus": "Microsoft.DBforMySQL.OperationStatus", + "azure.mgmt.mysqlflexibleservers.models.BackupFormat": "Microsoft.DBforMySQL.BackupFormat", + "azure.mgmt.mysqlflexibleservers.models.BackupType": "Microsoft.DBforMySQL.BackupType", + "azure.mgmt.mysqlflexibleservers.models.ProvisioningState": "Microsoft.DBforMySQL.ProvisioningState", + "azure.mgmt.mysqlflexibleservers.models.ConfigurationSource": "Microsoft.DBforMySQL.ConfigurationSource", + "azure.mgmt.mysqlflexibleservers.models.IsReadOnly": "Microsoft.DBforMySQL.IsReadOnly", + "azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart": "Microsoft.DBforMySQL.IsConfigPendingRestart", + "azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig": "Microsoft.DBforMySQL.IsDynamicConfig", + "azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault": "Microsoft.DBforMySQL.ResetAllToDefault", + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState": "Microsoft.DBforMySQL.AdvancedThreatProtectionState", + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState": "Microsoft.DBforMySQL.AdvancedThreatProtectionProvisioningState", + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionName": "Microsoft.DBforMySQL.AdvancedThreatProtectionName", + "azure.mgmt.mysqlflexibleservers.models.MaintenanceType": "Microsoft.DBforMySQL.MaintenanceType", + "azure.mgmt.mysqlflexibleservers.models.MaintenanceState": "Microsoft.DBforMySQL.MaintenanceState", + "azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState": "Microsoft.DBforMySQL.MaintenanceProvisioningState", + "azure.mgmt.mysqlflexibleservers.models.ObjectType": "Microsoft.DBforMySQL.ObjectType", + "azure.mgmt.mysqlflexibleservers.operations.Operations.list": "Microsoft.DBforMySQL.Operations.list", + "azure.mgmt.mysqlflexibleservers.aio.operations.Operations.list": "Microsoft.DBforMySQL.Operations.list", + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.get": "Microsoft.DBforMySQL.AzureADAdministrators.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.get": "Microsoft.DBforMySQL.AzureADAdministrators.get", + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_create_or_update": "Microsoft.DBforMySQL.AzureADAdministrators.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_create_or_update": "Microsoft.DBforMySQL.AzureADAdministrators.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_delete": "Microsoft.DBforMySQL.AzureADAdministrators.delete", + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_delete": "Microsoft.DBforMySQL.AzureADAdministrators.delete", + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.list_by_server": "Microsoft.DBforMySQL.AzureADAdministrators.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.list_by_server": "Microsoft.DBforMySQL.AzureADAdministrators.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.get": "Microsoft.DBforMySQL.Servers.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.get": "Microsoft.DBforMySQL.Servers.get", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_create": "Microsoft.DBforMySQL.Servers.create", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_create": "Microsoft.DBforMySQL.Servers.create", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_update": "Microsoft.DBforMySQL.Servers.update", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_update": "Microsoft.DBforMySQL.Servers.update", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_delete": "Microsoft.DBforMySQL.Servers.delete", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_delete": "Microsoft.DBforMySQL.Servers.delete", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list_by_resource_group": "Microsoft.DBforMySQL.Servers.listByResourceGroup", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list_by_resource_group": "Microsoft.DBforMySQL.Servers.listByResourceGroup", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list": "Microsoft.DBforMySQL.Servers.list", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list": "Microsoft.DBforMySQL.Servers.list", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_failover": "Microsoft.DBforMySQL.Servers.failover", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_failover": "Microsoft.DBforMySQL.Servers.failover", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.validate_estimate_high_availability": "Microsoft.DBforMySQL.Servers.validateEstimateHighAvailability", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.validate_estimate_high_availability": "Microsoft.DBforMySQL.Servers.validateEstimateHighAvailability", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_restart": "Microsoft.DBforMySQL.Servers.restart", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_restart": "Microsoft.DBforMySQL.Servers.restart", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_start": "Microsoft.DBforMySQL.Servers.start", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_start": "Microsoft.DBforMySQL.Servers.start", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_stop": "Microsoft.DBforMySQL.Servers.stop", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_stop": "Microsoft.DBforMySQL.Servers.stop", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_reset_gtid": "Microsoft.DBforMySQL.Servers.resetGtid", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_reset_gtid": "Microsoft.DBforMySQL.Servers.resetGtid", + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_detach_v_net": "Microsoft.DBforMySQL.Servers.detachVNet", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_detach_v_net": "Microsoft.DBforMySQL.Servers.detachVNet", + "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.begin_create": "Microsoft.DBforMySQL.BackupAndExport.create", + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.begin_create": "Microsoft.DBforMySQL.BackupAndExport.create", + "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.validate_backup": "Microsoft.DBforMySQL.BackupAndExport.validateBackup", + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.validate_backup": "Microsoft.DBforMySQL.BackupAndExport.validateBackup", + "azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations.list_by_server": "Microsoft.DBforMySQL.LogFiles.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations.list_by_server": "Microsoft.DBforMySQL.LogFiles.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations.begin_cutover_migration": "Microsoft.DBforMySQL.ServersMigration.cutoverMigration", + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations.begin_cutover_migration": "Microsoft.DBforMySQL.ServersMigration.cutoverMigration", + "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.get": "Microsoft.DBforMySQL.Backups.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.get": "Microsoft.DBforMySQL.Backups.get", + "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.put": "Microsoft.DBforMySQL.Backups.put", + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.put": "Microsoft.DBforMySQL.Backups.put", + "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.list_by_server": "Microsoft.DBforMySQL.Backups.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.list_by_server": "Microsoft.DBforMySQL.Backups.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.get": "Microsoft.DBforMySQL.LongRunningBackups.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.get": "Microsoft.DBforMySQL.LongRunningBackups.get", + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.list": "Microsoft.DBforMySQL.LongRunningBackups.list", + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.list": "Microsoft.DBforMySQL.LongRunningBackups.list", + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations.begin_create": "Microsoft.DBforMySQL.LongRunningBackup.create", + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupOperations.begin_create": "Microsoft.DBforMySQL.LongRunningBackup.create", + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations.begin_delete": "Microsoft.DBforMySQL.LongRunningBackup.delete", + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupOperations.begin_delete": "Microsoft.DBforMySQL.LongRunningBackup.delete", + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.get": "Microsoft.DBforMySQL.Configurations.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.get": "Microsoft.DBforMySQL.Configurations.get", + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_create_or_update": "Microsoft.DBforMySQL.Configurations.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_create_or_update": "Microsoft.DBforMySQL.Configurations.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_update": "Microsoft.DBforMySQL.Configurations.update", + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_update": "Microsoft.DBforMySQL.Configurations.update", + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.list_by_server": "Microsoft.DBforMySQL.Configurations.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.list_by_server": "Microsoft.DBforMySQL.Configurations.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_batch_update": "Microsoft.DBforMySQL.Configurations.batchUpdate", + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_batch_update": "Microsoft.DBforMySQL.Configurations.batchUpdate", + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.get": "Microsoft.DBforMySQL.Databases.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.get": "Microsoft.DBforMySQL.Databases.get", + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_create_or_update": "Microsoft.DBforMySQL.Databases.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_create_or_update": "Microsoft.DBforMySQL.Databases.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_delete": "Microsoft.DBforMySQL.Databases.delete", + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_delete": "Microsoft.DBforMySQL.Databases.delete", + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.list_by_server": "Microsoft.DBforMySQL.Databases.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.list_by_server": "Microsoft.DBforMySQL.Databases.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.get": "Microsoft.DBforMySQL.FirewallRules.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.get": "Microsoft.DBforMySQL.FirewallRules.get", + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DBforMySQL.FirewallRules.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DBforMySQL.FirewallRules.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_delete": "Microsoft.DBforMySQL.FirewallRules.delete", + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_delete": "Microsoft.DBforMySQL.FirewallRules.delete", + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.list_by_server": "Microsoft.DBforMySQL.FirewallRules.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.list_by_server": "Microsoft.DBforMySQL.FirewallRules.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.get": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.get": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.get", + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.updatePut", + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.updatePut", + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.update", + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.update", + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.list": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.list", + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.list": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.list", + "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.get": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.get": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.get", + "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.list", + "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.list", + "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.read": "Microsoft.DBforMySQL.Maintenances.read", + "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.read": "Microsoft.DBforMySQL.Maintenances.read", + "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.begin_update": "Microsoft.DBforMySQL.Maintenances.update", + "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.begin_update": "Microsoft.DBforMySQL.Maintenances.update", + "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.list": "Microsoft.DBforMySQL.Maintenances.list", + "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.list": "Microsoft.DBforMySQL.Maintenances.list", + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DBforMySQL.PrivateEndpointConnections.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DBforMySQL.PrivateEndpointConnections.get", + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.DBforMySQL.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.DBforMySQL.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DBforMySQL.PrivateEndpointConnections.delete", + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DBforMySQL.PrivateEndpointConnections.delete", + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.DBforMySQL.PrivateEndpointConnections.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.DBforMySQL.PrivateEndpointConnections.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.get": "Microsoft.DBforMySQL.PrivateLinkResources.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.get": "Microsoft.DBforMySQL.PrivateLinkResources.get", + "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.DBforMySQL.PrivateLinkResources.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.DBforMySQL.PrivateLinkResources.listByServer", + "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilities.list", + "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilities.list", + "azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations.execute": "Microsoft.DBforMySQL.CheckVirtualNetworkSubnetUsage.execute", + "azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations.execute": "Microsoft.DBforMySQL.CheckVirtualNetworkSubnetUsage.execute", + "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailability.execute", + "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailability.execute", + "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailabilityWithoutLocation.execute", + "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailabilityWithoutLocation.execute", + "azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations.get": "Microsoft.DBforMySQL.OperationResults.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations.get": "Microsoft.DBforMySQL.OperationResults.get", + "azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations.get": "Microsoft.DBforMySQL.OperationProgress.get", + "azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations.get": "Microsoft.DBforMySQL.OperationProgress.get", + "azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations.execute": "Microsoft.DBforMySQL.GetPrivateDnsZoneSuffix.execute", + "azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations.execute": "Microsoft.DBforMySQL.GetPrivateDnsZoneSuffix.execute", + "azure.mgmt.mysqlflexibleservers.operations.ReplicasOperations.list_by_server": "Microsoft.DBforMySQL.Replicas.listByServer", + "azure.mgmt.mysqlflexibleservers.aio.operations.ReplicasOperations.list_by_server": "Microsoft.DBforMySQL.Replicas.listByServer" } } \ No newline at end of file diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__init__.py index e811f4d2e769..35aa45b31e42 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__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 ._my_sql_management_client import MySQLManagementClient # type: ignore +from ._client import MySQLManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_my_sql_management_client.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_client.py similarity index 93% rename from sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_my_sql_management_client.py rename to sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_client.py index 3f799924a366..b170353b3c11 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_my_sql_management_client.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,7 +17,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 MySQLManagementClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( @@ -58,45 +57,21 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes Azure MySQL resources including servers, databases, firewall rules, VNET rules, log files and configurations with new business model. - :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations - :vartype get_private_dns_zone_suffix: - azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.mysqlflexibleservers.operations.Operations - :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations - operations - :vartype check_name_availability_without_location: - azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.mysqlflexibleservers.operations.ServersOperations - :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations - :vartype location_based_capabilities: - azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations - :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations - :vartype location_based_capability_set: - azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations - :ivar check_name_availability: CheckNameAvailabilityOperations operations - :vartype check_name_availability: - azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations - :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations - :vartype check_virtual_network_subnet_usage: - azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations - :ivar operation_progress: OperationProgressOperations operations - :vartype operation_progress: - azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations - :ivar operation_results: OperationResultsOperations operations - :vartype operation_results: - azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations :ivar azure_ad_administrators: AzureADAdministratorsOperations operations :vartype azure_ad_administrators: azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations - :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations - operations - :vartype advanced_threat_protection_settings: - azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.mysqlflexibleservers.operations.ServersOperations :ivar backup_and_export: BackupAndExportOperations operations :vartype backup_and_export: azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations + :ivar log_files: LogFilesOperations operations + :vartype log_files: azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations + :ivar servers_migration: ServersMigrationOperations operations + :vartype servers_migration: + azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations :ivar backups: BackupsOperations operations :vartype backups: azure.mgmt.mysqlflexibleservers.operations.BackupsOperations :ivar long_running_backups: LongRunningBackupsOperations operations @@ -107,15 +82,17 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations :ivar configurations: ConfigurationsOperations operations :vartype configurations: azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations - :ivar servers_migration: ServersMigrationOperations operations - :vartype servers_migration: - azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations :ivar databases: DatabasesOperations operations :vartype databases: azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations :ivar firewall_rules: FirewallRulesOperations operations :vartype firewall_rules: azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations - :ivar log_files: LogFilesOperations operations - :vartype log_files: azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations + :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations + operations + :vartype advanced_threat_protection_settings: + azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations + :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations + :vartype location_based_capability_set: + azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations :ivar maintenances: MaintenancesOperations operations :vartype maintenances: azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations @@ -124,19 +101,42 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations + :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations + :vartype location_based_capabilities: + azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations + :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations + :vartype check_virtual_network_subnet_usage: + azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations + :ivar check_name_availability: CheckNameAvailabilityOperations operations + :vartype check_name_availability: + azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations + :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations + operations + :vartype check_name_availability_without_location: + azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: + azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations + :ivar operation_progress: OperationProgressOperations operations + :vartype operation_progress: + azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations + :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations + :vartype get_private_dns_zone_suffix: + azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations :ivar replicas: ReplicasOperations operations :vartype replicas: azure.mgmt.mysqlflexibleservers.operations.ReplicasOperations - :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 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: Api Version. Default value is "2024-12-30". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-06-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. @@ -151,6 +151,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: @@ -159,6 +160,7 @@ def __init__( self._config = MySQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -182,77 +184,76 @@ 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.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( + self.azure_ad_administrators = AzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_based_capabilities = LocationBasedCapabilitiesOperations( + self.backup_and_export = BackupAndExportOperations( self._client, self._config, self._serialize, self._deserialize ) - self.location_based_capability_set = LocationBasedCapabilitySetOperations( + self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers_migration = ServersMigrationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_name_availability = CheckNameAvailabilityOperations( + self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_running_backups = LongRunningBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( + self.long_running_backup = LongRunningBackupOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_progress = OperationProgressOperations( + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_results = OperationResultsOperations( + self.location_based_capability_set = LocationBasedCapabilitySetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.azure_ad_administrators = AzureADAdministratorsOperations( + self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backup_and_export = BackupAndExportOperations( + self.location_based_capabilities = LocationBasedCapabilitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_running_backups = LongRunningBackupsOperations( + self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_running_backup = LongRunningBackupOperations( + self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.servers_migration = ServersMigrationOperations( + self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.operation_results = OperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.operation_progress = OperationProgressOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( self._client, self._config, self._serialize, self._deserialize ) self.replicas = ReplicasOperations(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 @@ -265,7 +266,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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_configuration.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_configuration.py index c94dbe74e679..b0b453dec88b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_configuration.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_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,15 +24,18 @@ class MySQLManagementClientConfiguration: # pylint: disable=too-many-instance-a 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 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: Api Version. Default value is "2024-12-30". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-06-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -40,10 +43,11 @@ 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", "2024-12-30") + api_version: str = kwargs.pop("api_version", "2025-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,6 +56,7 @@ 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"]) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py new file mode 100644 index 000000000000..12926fa98dcf --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py @@ -0,0 +1,1237 @@ +# 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") + + +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" +) + + +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 + + +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) + + +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 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: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + 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: + 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): + 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: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + 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 = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + 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 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._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_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 = prop_meta.get("ns", model_meta.get("ns", None)) + 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 _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) + 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 for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), 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 != type(None)] # 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 is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return 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 DeserializationError: + _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 DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +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, + ): + 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._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @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 + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + 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, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +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_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: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("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} + + # if no ns for prop, use model's + 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): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + 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 = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "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: + 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": parent_meta.get("itemsNs", parent_meta.get("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: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + 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 + + +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 _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/serialization.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/serialization.py index ff543ed937ff..45a3e44e45cb 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/serialization.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_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. # -------------------------------------------------------------------------- diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_validation.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py index 0ec13ea52bbf..22553b18fb7e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b4" diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/__init__.py index e557bb5173b5..d85e1983f06f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/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 ._my_sql_management_client import MySQLManagementClient # type: ignore +from ._client import MySQLManagementClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_my_sql_management_client.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_client.py similarity index 94% rename from sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_my_sql_management_client.py rename to sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_client.py index f94ebb5e242a..b79cf67bd9ab 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_my_sql_management_client.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,7 +17,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 MySQLManagementClientConfiguration from .operations import ( @@ -58,45 +57,21 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes Azure MySQL resources including servers, databases, firewall rules, VNET rules, log files and configurations with new business model. - :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations - :vartype get_private_dns_zone_suffix: - azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.mysqlflexibleservers.aio.operations.Operations - :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations - operations - :vartype check_name_availability_without_location: - azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations - :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations - :vartype location_based_capabilities: - azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations - :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations - :vartype location_based_capability_set: - azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations - :ivar check_name_availability: CheckNameAvailabilityOperations operations - :vartype check_name_availability: - azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations - :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations - :vartype check_virtual_network_subnet_usage: - azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations - :ivar operation_progress: OperationProgressOperations operations - :vartype operation_progress: - azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations - :ivar operation_results: OperationResultsOperations operations - :vartype operation_results: - azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations :ivar azure_ad_administrators: AzureADAdministratorsOperations operations :vartype azure_ad_administrators: azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations - :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations - operations - :vartype advanced_threat_protection_settings: - azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations :ivar backup_and_export: BackupAndExportOperations operations :vartype backup_and_export: azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations + :ivar log_files: LogFilesOperations operations + :vartype log_files: azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations + :ivar servers_migration: ServersMigrationOperations operations + :vartype servers_migration: + azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations :ivar backups: BackupsOperations operations :vartype backups: azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations :ivar long_running_backups: LongRunningBackupsOperations operations @@ -108,15 +83,17 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar configurations: ConfigurationsOperations operations :vartype configurations: azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations - :ivar servers_migration: ServersMigrationOperations operations - :vartype servers_migration: - azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations :ivar databases: DatabasesOperations operations :vartype databases: azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations :ivar firewall_rules: FirewallRulesOperations operations :vartype firewall_rules: azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations - :ivar log_files: LogFilesOperations operations - :vartype log_files: azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations + :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations + operations + :vartype advanced_threat_protection_settings: + azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations + :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations + :vartype location_based_capability_set: + azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations :ivar maintenances: MaintenancesOperations operations :vartype maintenances: azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations @@ -125,19 +102,42 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations + :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations + :vartype location_based_capabilities: + azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations + :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations + :vartype check_virtual_network_subnet_usage: + azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations + :ivar check_name_availability: CheckNameAvailabilityOperations operations + :vartype check_name_availability: + azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations + :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations + operations + :vartype check_name_availability_without_location: + azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: + azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations + :ivar operation_progress: OperationProgressOperations operations + :vartype operation_progress: + azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations + :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations + :vartype get_private_dns_zone_suffix: + azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations :ivar replicas: ReplicasOperations operations :vartype replicas: azure.mgmt.mysqlflexibleservers.aio.operations.ReplicasOperations - :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 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: Api Version. Default value is "2024-12-30". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-06-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. @@ -152,6 +152,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: @@ -160,6 +161,7 @@ def __init__( self._config = MySQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -184,72 +186,71 @@ 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.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( + self.azure_ad_administrators = AzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_based_capabilities = LocationBasedCapabilitiesOperations( + self.backup_and_export = BackupAndExportOperations( self._client, self._config, self._serialize, self._deserialize ) - self.location_based_capability_set = LocationBasedCapabilitySetOperations( + self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers_migration = ServersMigrationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_name_availability = CheckNameAvailabilityOperations( + self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_running_backups = LongRunningBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( + self.long_running_backup = LongRunningBackupOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_progress = OperationProgressOperations( + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_results = OperationResultsOperations( + self.location_based_capability_set = LocationBasedCapabilitySetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.azure_ad_administrators = AzureADAdministratorsOperations( + self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backup_and_export = BackupAndExportOperations( + self.location_based_capabilities = LocationBasedCapabilitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_running_backups = LongRunningBackupsOperations( + self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_running_backup = LongRunningBackupOperations( + self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.servers_migration = ServersMigrationOperations( + self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.operation_results = OperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.operation_progress = OperationProgressOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( self._client, self._config, self._serialize, self._deserialize ) self.replicas = ReplicasOperations(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. @@ -257,7 +258,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 @@ -270,7 +271,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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_configuration.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_configuration.py index c2fb615c4df0..b8e0b29c92f1 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_configuration.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/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,15 +24,18 @@ class MySQLManagementClientConfiguration: # pylint: disable=too-many-instance-a 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 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: Api Version. Default value is "2024-12-30". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-06-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -40,10 +43,11 @@ 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", "2024-12-30") + api_version: str = kwargs.pop("api_version", "2025-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,6 +56,7 @@ 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"]) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/__init__.py index f9cdf4c5b3fd..d833fa5e1131 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/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,61 +12,61 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._get_private_dns_zone_suffix_operations import GetPrivateDnsZoneSuffixOperations # type: ignore from ._operations import Operations # type: ignore -from ._check_name_availability_without_location_operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore -from ._servers_operations import ServersOperations # type: ignore -from ._location_based_capabilities_operations import LocationBasedCapabilitiesOperations # type: ignore -from ._location_based_capability_set_operations import LocationBasedCapabilitySetOperations # type: ignore -from ._check_name_availability_operations import CheckNameAvailabilityOperations # type: ignore -from ._check_virtual_network_subnet_usage_operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore -from ._operation_progress_operations import OperationProgressOperations # type: ignore -from ._operation_results_operations import OperationResultsOperations # type: ignore -from ._azure_ad_administrators_operations import AzureADAdministratorsOperations # type: ignore -from ._advanced_threat_protection_settings_operations import AdvancedThreatProtectionSettingsOperations # type: ignore -from ._backup_and_export_operations import BackupAndExportOperations # type: ignore -from ._backups_operations import BackupsOperations # type: ignore -from ._long_running_backups_operations import LongRunningBackupsOperations # type: ignore -from ._long_running_backup_operations import LongRunningBackupOperations # type: ignore -from ._configurations_operations import ConfigurationsOperations # type: ignore -from ._servers_migration_operations import ServersMigrationOperations # type: ignore -from ._databases_operations import DatabasesOperations # type: ignore -from ._firewall_rules_operations import FirewallRulesOperations # type: ignore -from ._log_files_operations import LogFilesOperations # type: ignore -from ._maintenances_operations import MaintenancesOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._replicas_operations import ReplicasOperations # type: ignore +from ._operations import AzureADAdministratorsOperations # type: ignore +from ._operations import ServersOperations # type: ignore +from ._operations import BackupAndExportOperations # type: ignore +from ._operations import LogFilesOperations # type: ignore +from ._operations import ServersMigrationOperations # type: ignore +from ._operations import BackupsOperations # type: ignore +from ._operations import LongRunningBackupsOperations # type: ignore +from ._operations import LongRunningBackupOperations # type: ignore +from ._operations import ConfigurationsOperations # type: ignore +from ._operations import DatabasesOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import AdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import LocationBasedCapabilitySetOperations # type: ignore +from ._operations import MaintenancesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import LocationBasedCapabilitiesOperations # type: ignore +from ._operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore +from ._operations import CheckNameAvailabilityOperations # type: ignore +from ._operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore +from ._operations import OperationResultsOperations # type: ignore +from ._operations import OperationProgressOperations # type: ignore +from ._operations import GetPrivateDnsZoneSuffixOperations # type: ignore +from ._operations import ReplicasOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "GetPrivateDnsZoneSuffixOperations", "Operations", - "CheckNameAvailabilityWithoutLocationOperations", - "ServersOperations", - "LocationBasedCapabilitiesOperations", - "LocationBasedCapabilitySetOperations", - "CheckNameAvailabilityOperations", - "CheckVirtualNetworkSubnetUsageOperations", - "OperationProgressOperations", - "OperationResultsOperations", "AzureADAdministratorsOperations", - "AdvancedThreatProtectionSettingsOperations", + "ServersOperations", "BackupAndExportOperations", + "LogFilesOperations", + "ServersMigrationOperations", "BackupsOperations", "LongRunningBackupsOperations", "LongRunningBackupOperations", "ConfigurationsOperations", - "ServersMigrationOperations", "DatabasesOperations", "FirewallRulesOperations", - "LogFilesOperations", + "AdvancedThreatProtectionSettingsOperations", + "LocationBasedCapabilitySetOperations", "MaintenancesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "LocationBasedCapabilitiesOperations", + "CheckVirtualNetworkSubnetUsageOperations", + "CheckNameAvailabilityOperations", + "CheckNameAvailabilityWithoutLocationOperations", + "OperationResultsOperations", + "OperationProgressOperations", + "GetPrivateDnsZoneSuffixOperations", "ReplicasOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py deleted file mode 100644 index 7bcfe6dc8063..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,678 +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 -import urllib.parse - -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._advanced_threat_protection_settings_operations import ( - build_get_request, - build_list_request, - build_update_put_request, - build_update_request, -) -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.AdvancedThreatProtection"]: - """Gets a list of 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 either AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.AdvancedThreatProtection: - """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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :return: AdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtection] = 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_put_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, 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", self._config.api_version)) - 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, "AdvancedThreatProtection") - - _request = build_update_put_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, 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 == 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.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_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_put( - 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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is either a - AdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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_put_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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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", self._config.api_version)) - 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, "AdvancedThreatProtectionForUpdate") - - _request = build_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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtectionForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate - :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is either a - AdvancedThreatProtectionForUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - 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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py deleted file mode 100644 index 82a01815bb33..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py +++ /dev/null @@ -1,575 +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 -import urllib.parse - -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._azure_ad_administrators_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class AzureADAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.AzureADAdministrator"]: - """List all the AAD administrators in 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 - :return: An iterator like instance of either AzureADAdministrator or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - 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, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> _models.AzureADAdministrator: - """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :return: AzureADAdministrator or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AzureADAdministrator] = 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureADAdministrator", 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.AzureADAdministrator, 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", self._config.api_version)) - 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, "AzureADAdministrator") - - _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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_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.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, - administrator_name: Union[str, _models.AdministratorName], - parameters: _models.AzureADAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :keyword content_type: Body Parameter 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 AzureADAdministrator or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: IO[bytes] - :keyword content_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 AzureADAdministrator or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. Is - either a AzureADAdministrator type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AzureADAdministrator or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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("AzureADAdministrator", 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.AzureADAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureADAdministrator]( - 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", self._config.api_version)) - 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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_operations.py deleted file mode 100644 index 7d7b2308fb84..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_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 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._backup_and_export_operations import build_create_request, build_validate_backup_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class BackupAndExportOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`backup_and_export` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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.BackupAndExportRequest, 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", self._config.api_version)) - 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, "BackupAndExportRequest") - - _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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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( - self, - resource_group_name: str, - server_name: str, - parameters: _models.BackupAndExportRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest - :keyword content_type: Body Parameter 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 BackupAndExportResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: IO[bytes] - :keyword content_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 BackupAndExportResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupAndExportRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Is either a BackupAndExportRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupAndExportResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupAndExportResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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): - deserialized = self._deserialize("BackupAndExportResponse", 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.BackupAndExportResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.BackupAndExportResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def validate_backup( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> _models.ValidateBackupResponse: - """Validates if backup can be performed for 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 - :return: ValidateBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) - - _request = build_validate_backup_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateBackupResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py deleted file mode 100644 index 3d0ad5e14d75..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py +++ /dev/null @@ -1,272 +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 -import urllib.parse - -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._backups_operations import build_get_request, build_list_by_server_request, build_put_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class BackupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.ServerBackup"]: - """List all the backups 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 - :return: An iterator like instance of either ServerBackup or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerBackupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, backup_name: str, **kwargs: Any - ) -> _models.ServerBackup: - """List all the backups 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_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("ServerBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def put( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> _models.ServerBackup: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_put_request( - resource_group_name=resource_group_name, - server_name=server_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("ServerBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py deleted file mode 100644 index 35fee375a974..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py +++ /dev/null @@ -1,177 +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._check_name_availability_operations import build_execute_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class CheckNameAvailabilityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, - location_name: str, - name_availability_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def execute( - self, - location_name: str, - name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or - a IO[bytes] type. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") - - _request = build_execute_request( - location_name=location_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py deleted file mode 100644 index 16341e2fa228..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py +++ /dev/null @@ -1,161 +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._check_name_availability_without_location_operations import build_execute_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`check_name_availability_without_location` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def execute( - self, name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or - a IO[bytes] type. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") - - _request = build_execute_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("NameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py deleted file mode 100644 index bc283d9e045b..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py +++ /dev/null @@ -1,171 +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._check_virtual_network_subnet_usage_operations import build_execute_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class CheckVirtualNetworkSubnetUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - parameters: _models.VirtualNetworkSubnetUsageParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :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: VirtualNetworkSubnetUsageResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def execute( - self, - location_name: str, - parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Is either a VirtualNetworkSubnetUsageParameter type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or - IO[bytes] - :return: VirtualNetworkSubnetUsageResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") - - _request = build_execute_request( - location_name=location_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualNetworkSubnetUsageResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py deleted file mode 100644 index 3a36694b42ab..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py +++ /dev/null @@ -1,884 +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 -import urllib.parse - -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._configurations_operations import ( - build_batch_update_request, - build_create_or_update_request, - build_get_request, - build_list_by_server_request, - build_update_request, -) -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`configurations` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, - tags: Optional[str] = None, - keyword: Optional[str] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Configuration"]: - """List all the configurations in 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 tags: The tags of the server configuration. Default value is None. - :type tags: str - :param keyword: The keyword of the server configuration. Default value is None. - :type keyword: str - :param page: The page of the server configuration. Default value is None. - :type page: int - :param page_size: The pageSize of the server configuration. Default value is None. - :type page_size: int - :return: An iterator like instance of either Configuration or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - tags=tags, - keyword=keyword, - page=page, - page_size=page_size, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ConfigurationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, configuration_name: str, **kwargs: Any - ) -> _models.Configuration: - """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :return: Configuration or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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("Configuration", 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, - configuration_name: str, - parameters: Union[_models.Configuration, 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", self._config.api_version)) - 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, "Configuration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter 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 Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is either a - Configuration type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, 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", self._config.api_version)) - 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, "Configuration") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter 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 Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is either a - Configuration type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Configuration or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _batch_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, 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", self._config.api_version)) - 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, "ConfigurationListForBatchUpdate") - - _request = build_batch_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ConfigurationListForBatchUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate - :keyword content_type: Body Parameter 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 ConfigurationListResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 ConfigurationListResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Is either a - ConfigurationListForBatchUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either ConfigurationListResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._batch_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("ConfigurationListResult", 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.ConfigurationListResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConfigurationListResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py deleted file mode 100644 index c5be56ff636e..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py +++ /dev/null @@ -1,557 +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 -import urllib.parse - -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_get_request, - build_list_by_server_request, -) -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Database"]: - """List all the databases in 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 - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - 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, **kwargs: Any - ) -> _models.Database: - """Gets information about 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: Database or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - 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("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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_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.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, - 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 required parameters for creating or updating a database. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: 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 required parameters for creating or updating a database. Is either a - Database type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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": "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 _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", self._config.api_version)) - 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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - 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 diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py deleted file mode 100644 index dd8e7566a8e3..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py +++ /dev/null @@ -1,560 +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 -import urllib.parse - -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._firewall_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import MySQLManagementClientConfiguration - -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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.FirewallRule"]: - """List all the firewall rules in 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 - :return: An iterator like instance of either FirewallRule or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - 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, firewall_rule_name: str, **kwargs: Any - ) -> _models.FirewallRule: - """Gets information about a server 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 server firewall rule. Required. - :type firewall_rule_name: str - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("FirewallRule", 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, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, 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", self._config.api_version)) - 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, "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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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 == 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.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, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of AsyncLROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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 - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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: An instance of AsyncLROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or IO[bytes] - :return: An instance of AsyncLROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - firewall_rule_name=firewall_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("FirewallRule", 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.FirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, firewall_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", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, firewall_rule_name: str, **kwargs: Any - ) -> AsyncLROPoller[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 server firewall rule. Required. - :type firewall_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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py deleted file mode 100644 index 33e3387ff56c..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py +++ /dev/null @@ -1,104 +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._get_private_dns_zone_suffix_operations import build_execute_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class GetPrivateDnsZoneSuffixOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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 execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: - """Get private DNS zone suffix in the cloud. - - :return: GetPrivateDnsZoneSuffixResponse or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) - - _request = build_execute_request( - 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("GetPrivateDnsZoneSuffixResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py deleted file mode 100644 index bb4758d07680..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py +++ /dev/null @@ -1,138 +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 -import urllib.parse - -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._location_based_capabilities_operations import build_list_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LocationBasedCapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.CapabilityProperties"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either CapabilityProperties or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilitiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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( - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilitiesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py deleted file mode 100644 index f763588a5e25..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py +++ /dev/null @@ -1,196 +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 -import urllib.parse - -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._location_based_capability_set_operations import build_get_request, build_list_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LocationBasedCapabilitySetOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`location_based_capability_set` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilitySetsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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( - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilitySetsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, capability_set_name: str = "default", **kwargs: Any) -> _models.Capability: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :param capability_set_name: Name of capability set. Default value is "default". - :type capability_set_name: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Capability] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - capability_set_name=capability_set_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Capability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py deleted file mode 100644 index 9635b8c664e5..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py +++ /dev/null @@ -1,143 +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 -import urllib.parse - -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._log_files_operations import build_list_by_server_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LogFilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`log_files` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: - """List all the server log files in 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 - :return: An iterator like instance of either LogFile or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.LogFileListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LogFileListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_operations.py deleted file mode 100644 index 854c82c16da2..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_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, 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._long_running_backup_operations import build_create_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LongRunningBackupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`long_running_backup` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ServerBackupV2") - else: - _json = None - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_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, 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 == 201: - 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.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( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[_models.ServerBackupV2] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :keyword content_type: Body Parameter 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 ServerBackupV2 or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: IO[bytes] - :keyword content_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 ServerBackupV2 or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Is either a ServerBackupV2 type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerBackupV2 or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - 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("ServerBackupV2", 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.ServerBackupV2].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerBackupV2]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py deleted file mode 100644 index 4aed724c87fb..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py +++ /dev/null @@ -1,208 +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 -import urllib.parse - -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._long_running_backups_operations import build_get_request, build_list_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LongRunningBackupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`long_running_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ServerBackupV2"]: - """List all the backups 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 - :return: An iterator like instance of either ServerBackupV2 or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackupV2ListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerBackupV2ListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, backup_name: str, **kwargs: Any - ) -> _models.ServerBackupV2: - """Get backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackupV2 or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_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("ServerBackupV2", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py deleted file mode 100644 index e408e977e096..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py +++ /dev/null @@ -1,433 +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 -import urllib.parse - -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._maintenances_operations import build_list_request, build_read_request, build_update_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class MaintenancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`maintenances` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Maintenance"]: - """List maintenances. - - :param resource_group_name: The name of the resource group. 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 either Maintenance or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.MaintenanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MaintenanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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 read( - self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any - ) -> _models.Maintenance: - """Read maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :return: Maintenance or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - - _request = build_read_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_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("Maintenance", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "MaintenanceUpdate") - else: - _json = None - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - maintenance_name: str, - parameters: Optional[_models.MaintenanceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate - :keyword content_type: Body Parameter 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 Maintenance or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: IO[bytes] - :keyword content_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 Maintenance or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Is either a - MaintenanceUpdate type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Maintenance or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - maintenance_name=maintenance_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("Maintenance", 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.Maintenance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Maintenance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py deleted file mode 100644 index ffe58057466e..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py +++ /dev/null @@ -1,113 +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._operation_progress_operations import build_get_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class OperationProgressOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationProgressResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) - - _request = build_get_request( - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationProgressResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py deleted file mode 100644 index 83c6d8c032c9..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py +++ /dev/null @@ -1,113 +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._operation_results_operations import build_get_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class OperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationStatusExtendedResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) - - _request = build_get_request( - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusExtendedResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py index f8cf9e654266..d62daed157a0 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py @@ -1,12 +1,15 @@ +# 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. +# 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 +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -17,21 +20,95 @@ 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_advanced_threat_protection_settings_get_request, + build_advanced_threat_protection_settings_list_request, + build_advanced_threat_protection_settings_update_put_request, + build_advanced_threat_protection_settings_update_request, + build_azure_ad_administrators_create_or_update_request, + build_azure_ad_administrators_delete_request, + build_azure_ad_administrators_get_request, + build_azure_ad_administrators_list_by_server_request, + build_backup_and_export_create_request, + build_backup_and_export_validate_backup_request, + build_backups_get_request, + build_backups_list_by_server_request, + build_backups_put_request, + build_check_name_availability_execute_request, + build_check_name_availability_without_location_execute_request, + build_check_virtual_network_subnet_usage_execute_request, + build_configurations_batch_update_request, + build_configurations_create_or_update_request, + build_configurations_get_request, + build_configurations_list_by_server_request, + build_configurations_update_request, + build_databases_create_or_update_request, + build_databases_delete_request, + build_databases_get_request, + build_databases_list_by_server_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_get_private_dns_zone_suffix_execute_request, + build_location_based_capabilities_list_request, + build_location_based_capability_set_get_request, + build_location_based_capability_set_list_request, + build_log_files_list_by_server_request, + build_long_running_backup_create_request, + build_long_running_backup_delete_request, + build_long_running_backups_get_request, + build_long_running_backups_list_request, + build_maintenances_list_request, + build_maintenances_read_request, + build_maintenances_update_request, + build_operation_progress_get_request, + build_operation_results_get_request, + build_operations_list_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_replicas_list_by_server_request, + build_servers_create_request, + build_servers_delete_request, + build_servers_detach_v_net_request, + build_servers_failover_request, + build_servers_get_request, + build_servers_list_by_resource_group_request, + build_servers_list_request, + build_servers_migration_cutover_migration_request, + build_servers_reset_gtid_request, + build_servers_restart_request, + build_servers_start_request, + build_servers_stop_request, + build_servers_update_request, + build_servers_validate_estimate_high_availability_request, +) from .._configuration import MySQLManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list @@ -45,8 +122,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") @@ -58,16 +133,596 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """List the operations for the provider. - :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.mysqlflexibleservers.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 AzureADAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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.AzureADAdministrator: + """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :return: AzureADAdministrator. The AzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) + + _request = build_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) + + _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() + else: + deserialized = _deserialize(_models.AzureADAdministrator, 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.AzureADAdministrator, 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_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) + + _stream = True + pipeline_response: PipelineResponse = await 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 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.AzureADAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AzureADAdministrator. The + AzureADAdministrator is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: 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 AzureADAdministrator. The + AzureADAdministrator is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: IO[bytes] + :keyword content_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 AzureADAdministrator. The + AzureADAdministrator is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. Is + one of the following types: AzureADAdministrator, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns AzureADAdministrator. The + AzureADAdministrator is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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.AzureADAdministrator, 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.AzureADAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureADAdministrator]( + 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_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) + + _stream = True + pipeline_response: PipelineResponse = await self._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 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 an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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.AzureADAdministrator"]: + """List all the AAD administrators in 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 + :return: An iterator like instance of AzureADAdministrator + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AzureADAdministrator]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -80,12 +735,20 @@ 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_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, ) - _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: # make call to next link with the client's api-version @@ -100,16 +763,8723 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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.AzureADAdministrator], 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: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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.Server: + """Gets information about 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: Server. The Server is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Server, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_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_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) + + _stream = True + pipeline_response: PipelineResponse = await 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 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.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] + :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[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: 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.mysqlflexibleservers.models.Server] + :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[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Is one of the + following types: Server, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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_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.ServerForUpdate, 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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 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.ServerForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate + :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.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.ServerForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is one of the following + types: ServerForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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) + + _stream = True + pipeline_response: PipelineResponse = await self._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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + 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, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: + """List all the servers in a given 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 Server + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: + """List all the servers in a given subscription. + + :return: An iterator like instance of Server + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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 _failover_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_failover_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 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, **kwargs: Any) -> AsyncLROPoller[None]: + """Manual failover 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._failover_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 + + @overload + async def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: _models.HighAvailabilityValidationEstimation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.HighAvailabilityValidationEstimation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is + one of the following types: HighAvailabilityValidationEstimation, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + or JSON or IO[bytes] + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~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.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) + + content_type = content_type or "application/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_validate_estimate_high_availability_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) + + _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() + else: + deserialized = _deserialize(_models.HighAvailabilityValidationEstimation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _restart_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, 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_restart_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerRestartParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter + :keyword content_type: Body Parameter 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: IO[bytes] + :keyword content_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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts 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 required parameters for restarting a server. Is one of the following + types: ServerRestartParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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._restart_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 + + async def _start_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_start_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 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, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Starts 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._start_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 + + async def _stop_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_stop_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 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, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Stops 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._stop_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 + + async def _reset_gtid_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, 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_reset_gtid_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerGtidSetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter + :keyword content_type: Body Parameter 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: IO[bytes] + :keyword content_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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Is one of the + following types: ServerGtidSetParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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._reset_gtid_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 + + async def _detach_v_net_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, 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_detach_v_net_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerDetachVNetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter + :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: 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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Is one of the following + types: ServerDetachVNetParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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._detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Server, 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.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 + ) + + +class BackupAndExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`backup_and_export` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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.BackupAndExportRequest, 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_and_export_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 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.BackupAndExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: 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 BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: IO[bytes] + :keyword content_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 BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupAndExportRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Is one of the following types: BackupAndExportRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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.BackupAndExportResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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): + 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.BackupAndExportResponse, 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.BackupAndExportResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupAndExportResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def validate_backup( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> _models.ValidateBackupResponse: + """Validates if backup can be performed for 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 + :return: ValidateBackupResponse. The ValidateBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) + + _request = build_backup_and_export_validate_backup_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) + + _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() + else: + deserialized = _deserialize(_models.ValidateBackupResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class LogFilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`log_files` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: + """List all the server log files in 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 + :return: An iterator like instance of LogFile + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LogFile]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_log_files_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.LogFile], 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 ServersMigrationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`servers_migration` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 _cutover_migration_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_migration_cutover_migration_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_cutover_migration( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible + 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 Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Server, 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.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 + ) + + +class BackupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, backup_name: str, **kwargs: Any + ) -> _models.ServerBackup: + """List all the backups 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup. The ServerBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_backups_get_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _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() + else: + deserialized = _deserialize(_models.ServerBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def put( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> _models.ServerBackup: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup. The ServerBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_backups_put_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _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() + else: + deserialized = _deserialize(_models.ServerBackup, 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.ServerBackup"]: + """List all the backups 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 + :return: An iterator like instance of ServerBackup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_backups_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.ServerBackup], 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 LongRunningBackupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`long_running_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, backup_name: str, **kwargs: Any + ) -> _models.ServerBackupV2: + """Get backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackupV2. The ServerBackupV2 is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + + _request = build_long_running_backups_get_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _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() + else: + deserialized = _deserialize(_models.ServerBackupV2, 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, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerBackupV2"]: + """List all the backups 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 + :return: An iterator like instance of ServerBackupV2 + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerBackupV2]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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_running_backups_list_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.ServerBackupV2], 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 LongRunningBackupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`long_running_backup` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_long_running_backup_create_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _stream = True + pipeline_response: PipelineResponse = await 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["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 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, + backup_name: str, + parameters: Optional[_models.ServerBackupV2] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerBackupV2. The ServerBackupV2 is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: 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 ServerBackupV2. The ServerBackupV2 is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: IO[bytes] + :keyword content_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 ServerBackupV2. The ServerBackupV2 is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Is one of the following types: ServerBackupV2, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerBackupV2. The ServerBackupV2 is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :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)) + content_type = content_type if parameters else None + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + 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.ServerBackupV2, 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.ServerBackupV2].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerBackupV2]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-06-01-preview", + params_added_on={ + "2025-06-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "server_name", + "backup_name", + ] + }, + api_versions_list=["2025-06-01-preview"], + ) + async def _delete_initial( + self, resource_group_name: str, server_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_running_backup_delete_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-06-01-preview", + params_added_on={ + "2025-06-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "server_name", + "backup_name", + ] + }, + api_versions_list=["2025-06-01-preview"], + ) + async def begin_delete( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete backup for a given server with specified backup 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 backup_name: The name of the backup. 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( + resource_group_name=resource_group_name, + server_name=server_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 + + +class ConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, configuration_name: str, **kwargs: Any + ) -> _models.Configuration: + """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :return: Configuration. The Configuration is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + + _request = build_configurations_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Configuration, 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, + configuration_name: str, + parameters: Union[_models.Configuration, 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_configurations_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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 = True + pipeline_response: PipelineResponse = await self._client._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 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: 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 Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is one of the + following types: Configuration, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :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.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, 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_configurations_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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 = True + pipeline_response: PipelineResponse = await self._client._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 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: 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 Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is one of the + following types: Configuration, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :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.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Configuration]( + 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, + *, + tags: Optional[str] = None, + keyword: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Configuration"]: + """List all the configurations in 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 + :keyword tags: The tags of the server configuration. Default value is None. + :paramtype tags: str + :keyword keyword: The keyword of the server configuration. Default value is None. + :paramtype keyword: str + :keyword page: The page of the server configuration. Default value is None. + :paramtype page: int + :keyword page_size: The pageSize of the server configuration. Default value is None. + :paramtype page_size: int + :return: An iterator like instance of Configuration + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Configuration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_configurations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + tags=tags, + keyword=keyword, + page=page, + page_size=page_size, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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.Configuration], 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 _batch_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, 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_configurations_batch_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ConfigurationListForBatchUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: 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 ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Is one of the + following types: ConfigurationListForBatchUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :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.ConfigurationListResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._batch_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.ConfigurationListResult, 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.ConfigurationListResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ConfigurationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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.Database: + """Gets information about 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: Database. The Database is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + 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) + + _stream = True + pipeline_response: PipelineResponse = await 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 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 required parameters for creating or updating a database. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a database. Is one of the + following types: Database, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 _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) + + _stream = True + pipeline_response: PipelineResponse = await self._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 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 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 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 + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Database"]: + """List all the databases in 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 + :return: An iterator like instance of Database + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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 information about a server 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 server firewall rule. Required. + :type firewall_rule_name: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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) + + _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() + else: + deserialized = _deserialize(_models.FirewallRule, 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, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, 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_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) + + _stream = True + pipeline_response: PipelineResponse = await 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 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, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_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 + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :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.FirewallRule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + firewall_rule_name=firewall_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.FirewallRule, 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.FirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, firewall_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_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 = True + pipeline_response: PipelineResponse = await self._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 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, firewall_rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[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 server firewall rule. Required. + :type firewall_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, + firewall_rule_name=firewall_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.FirewallRule"]: + """List all the firewall rules in 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 + :return: An iterator like instance of FirewallRule + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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) + + +class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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.AdvancedThreatProtection: + """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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :return: AdvancedThreatProtection. The AdvancedThreatProtection is compatible with + MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_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) + + _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() + else: + deserialized = _deserialize(_models.AdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, 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_advanced_threat_protection_settings_update_put_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) + + _stream = True + pipeline_response: PipelineResponse = await 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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + 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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: 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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + 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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is one of the + following types: AdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :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.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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_put_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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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_advanced_threat_protection_settings_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) + + _stream = True + pipeline_response: PipelineResponse = await self._client._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 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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtectionForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: 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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is one of the + following types: AdvancedThreatProtectionForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :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.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + 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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AdvancedThreatProtection"]: + """Gets a list of 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 AdvancedThreatProtection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_advanced_threat_protection_settings_list_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.AdvancedThreatProtection], 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 LocationBasedCapabilitySetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`location_based_capability_set` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, capability_set_name: str, **kwargs: Any) -> _models.Capability: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :param capability_set_name: Name of capability set. Required. + :type capability_set_name: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Capability] = kwargs.pop("cls", None) + + _request = build_location_based_capability_set_get_request( + location_name=location_name, + capability_set_name=capability_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Capability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of Capability + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_location_based_capability_set_list_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.Capability], 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 MaintenancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`maintenances` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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 read( + self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any + ) -> _models.Maintenance: + """Read maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :return: Maintenance. The Maintenance is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + + _request = build_maintenances_read_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Maintenance, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_maintenances_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_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 = True + pipeline_response: PipelineResponse = await self._client._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 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, + maintenance_name: str, + parameters: Optional[_models.MaintenanceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Maintenance. The Maintenance is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: 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 Maintenance. The Maintenance is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: IO[bytes] + :keyword content_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 Maintenance. The Maintenance is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Is one of the + following types: MaintenanceUpdate, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Maintenance. The Maintenance is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :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)) + content_type = content_type if parameters else None + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + maintenance_name=maintenance_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.Maintenance, 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.Maintenance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Maintenance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Maintenance"]: + """List maintenances. + + :param resource_group_name: The name of the resource group. 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 Maintenance + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Maintenance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_maintenances_list_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.Maintenance], 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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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) + + _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() + 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) + + _stream = True + pipeline_response: PipelineResponse = await 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["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 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create 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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create 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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Is one of the following types: + PrivateEndpointConnection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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) + + _stream = True + pipeline_response: PipelineResponse = await self._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 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 associated + with the Azure resource. 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_async + async def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionListResult: + """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: PrivateEndpointConnectionListResult. The PrivateEndpointConnectionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + _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) + + _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() + else: + deserialized = _deserialize(_models.PrivateEndpointConnectionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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 MySQL 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.mysqlflexibleservers.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) + + _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() + 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"]: + """Lists the private link resources for MySQL 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.mysqlflexibleservers.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 None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=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 LocationBasedCapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.CapabilityProperties"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of CapabilityProperties + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapabilityProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_location_based_capabilities_list_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.CapabilityProperties], 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 CheckVirtualNetworkSubnetUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + parameters: _models.VirtualNetworkSubnetUsageParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def execute( + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is one of the following types: + VirtualNetworkSubnetUsageParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or + JSON or IO[bytes] + :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~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.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_check_virtual_network_subnet_usage_execute_request( + location_name=location_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 = 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() + else: + deserialized = _deserialize(_models.VirtualNetworkSubnetUsageResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class CheckNameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, + location_name: str, + name_availability_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, + location_name: str, + name_availability_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def execute( + self, + location_name: str, + name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Is one of the following types: + NameAvailabilityRequest, JSON, IO[bytes] Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_check_name_availability_execute_request( + location_name=location_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 = 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() + else: + deserialized = _deserialize(_models.NameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`check_name_availability_without_location` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, name_availability_request: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def execute( + self, name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Is one of the following types: + NameAvailabilityRequest, JSON, IO[bytes] Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_check_name_availability_without_location_execute_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) + + _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() + else: + deserialized = _deserialize(_models.NameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class OperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusExtendedResult. The OperationStatusExtendedResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) + + _request = build_operation_results_get_request( + 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) + + _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() + else: + deserialized = _deserialize(_models.OperationStatusExtendedResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class OperationProgressOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationProgressResult. The OperationProgressResult is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) + + _request = build_operation_progress_get_request( + 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) + + _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() + else: + deserialized = _deserialize(_models.OperationProgressResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class GetPrivateDnsZoneSuffixOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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 execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: + """Get private DNS zone suffix in the cloud. + + :return: GetPrivateDnsZoneSuffixResponse. The GetPrivateDnsZoneSuffixResponse is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) + + _request = build_get_private_dns_zone_suffix_execute_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) + + _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() + else: + deserialized = _deserialize(_models.GetPrivateDnsZoneSuffixResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`replicas` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Server"]: + """List all the replicas 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 + :return: An iterator like instance of Server + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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_replicas_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 = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + 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.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) @@ -122,9 +9492,9 @@ 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) - error = self._deserialize.failsafe_deserialize( + error = _failsafe_deserialize( _models.ErrorResponse, - pipeline_response, + response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index e592afb55bc1..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_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.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._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import MySQLManagementClientConfiguration - -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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, **kwargs: Any - ) -> _models.PrivateEndpointConnectionListResult: - """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: PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_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("PrivateEndpointConnectionListResult", 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, 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, 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", self._config.api_version)) - 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, 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 == 201: - 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.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, - 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create 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.mysqlflexibleservers.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. The 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Is either a PrivateEndpointConnection type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, 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.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", self._config.api_version)) - 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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, 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 associated - with the Azure resource. 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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 6c6f669a8148..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,178 +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._private_link_resources_operations import build_get_request, build_list_by_server_request -from .._configuration import MySQLManagementClientConfiguration - -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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Lists the private link resources for MySQL 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: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - 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("PrivateLinkResourceListResult", 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, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets a private link resource for MySQL 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 or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py deleted file mode 100644 index 90a042e79e51..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py +++ /dev/null @@ -1,142 +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 -import urllib.parse - -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._replicas_operations import build_list_by_server_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ReplicasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`replicas` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Server"]: - """List all the replicas 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 - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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_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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py deleted file mode 100644 index 96953850489c..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py +++ /dev/null @@ -1,182 +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._servers_migration_operations import build_cutover_migration_request -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServersMigrationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`servers_migration` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 _cutover_migration_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", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_cutover_migration( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible - 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 either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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._cutover_migration_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("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, 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.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 - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py deleted file mode 100644 index 1fad026f5398..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py +++ /dev/null @@ -1,1903 +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 -import urllib.parse - -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_create_request, - build_delete_request, - build_detach_v_net_request, - build_failover_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_reset_gtid_request, - build_restart_request, - build_start_request, - build_stop_request, - build_update_request, - build_validate_estimate_high_availability_request, -) -from .._configuration import MySQLManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServersOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Server"]: - """List all the servers in a given subscription. - - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: - """List all the servers in a given 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 either Server or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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, **kwargs: Any) -> _models.Server: - """Gets information about 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: Server or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - 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_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", self._config.api_version)) - 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_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 == 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.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( - self, - resource_group_name: str, - server_name: str, - parameters: _models.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] - :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[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Is either a - Server type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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): - 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, 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.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.ServerForUpdate, 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", self._config.api_version)) - 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, "ServerForUpdate") - - _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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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.ServerForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate - :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.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.ServerForUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is either a ServerForUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, 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.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", self._config.api_version)) - 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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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. 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - 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, 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[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 _detach_v_net_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, 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", self._config.api_version)) - 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, "ServerDetachVNetParameter") - - _request = build_detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerDetachVNetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter - :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Is either a - ServerDetachVNetParameter type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._detach_v_net_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, 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.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 _failover_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", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_failover(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Manual failover 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._failover_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, 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 _reset_gtid_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, 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", self._config.api_version)) - 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, "ServerGtidSetParameter") - - _request = build_reset_gtid_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerGtidSetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter - :keyword content_type: Body Parameter 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: IO[bytes] - :keyword content_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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Is either a - ServerGtidSetParameter type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reset_gtid_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, 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[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 _restart_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, 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", self._config.api_version)) - 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, "ServerRestartParameter") - - _request = build_restart_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerRestartParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter - :keyword content_type: Body Parameter 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: IO[bytes] - :keyword content_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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts 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 required parameters for restarting a server. Is either a - ServerRestartParameter type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_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, 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 _start_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", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_start_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Starts 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_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, 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 _stop_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", self._config.api_version)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_stop_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Stops 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._stop_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, 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 - - @overload - async def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: _models.HighAvailabilityValidationEstimation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.HighAvailabilityValidationEstimation, IO[bytes]], - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is - either a HighAvailabilityValidationEstimation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - or IO[bytes] - :return: HighAvailabilityValidationEstimation or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "HighAvailabilityValidationEstimation") - - _request = build_validate_estimate_high_availability_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("HighAvailabilityValidationEstimation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__init__.py index 7166d8ff057b..dc2040884f1f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__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 @@ -13,37 +13,40 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore - AdministratorListResult, +from ._models import ( # type: ignore + AdministratorProperties, AdvancedThreatProtection, AdvancedThreatProtectionForUpdate, - AdvancedThreatProtectionListResult, + AdvancedThreatProtectionProperties, + AdvancedThreatProtectionUpdateProperties, AzureADAdministrator, Backup, BackupAndExportRequest, BackupAndExportResponse, + BackupAndExportResponseProperties, BackupAndExportResponseType, BackupRequestBase, BackupSettings, BackupStoreDetails, - CapabilitiesListResult, Capability, CapabilityProperties, - CapabilitySetsList, + CapabilityPropertiesV2, Configuration, ConfigurationForBatchUpdate, + ConfigurationForBatchUpdateProperties, ConfigurationListForBatchUpdate, ConfigurationListResult, + ConfigurationProperties, DataEncryption, Database, - DatabaseListResult, + DatabaseProperties, DelegatedSubnetUsage, ErrorAdditionalInfo, ErrorDetail, ErrorResponse, FeatureProperty, FirewallRule, - FirewallRuleListResult, + FirewallRuleProperties, FullBackupStoreDetails, GetPrivateDnsZoneSuffixResponse, HighAvailability, @@ -51,10 +54,11 @@ ImportFromStorageResponseType, ImportSourceProperties, LogFile, - LogFileListResult, + LogFileProperties, Maintenance, - MaintenanceListResult, MaintenancePolicy, + MaintenanceProperties, + MaintenancePropertiesForUpdate, MaintenanceUpdate, MaintenanceWindow, MySQLServerIdentity, @@ -64,7 +68,6 @@ Network, Operation, OperationDisplay, - OperationListResult, OperationProgressResponseType, OperationProgressResult, OperationStatusExtendedResult, @@ -72,22 +75,24 @@ PrivateEndpoint, PrivateEndpointConnection, PrivateEndpointConnectionListResult, + PrivateEndpointConnectionProperties, PrivateLinkResource, - PrivateLinkResourceListResult, + PrivateLinkResourceProperties, PrivateLinkServiceConnectionState, ProxyResource, Resource, Server, ServerBackup, - ServerBackupListResult, + ServerBackupProperties, + ServerBackupPropertiesV2, ServerBackupV2, - ServerBackupV2ListResult, ServerDetachVNetParameter, ServerEditionCapability, ServerEditionCapabilityV2, ServerForUpdate, ServerGtidSetParameter, - ServerListResult, + ServerProperties, + ServerPropertiesForUpdate, ServerRestartParameter, ServerVersionCapability, ServerVersionCapabilityV2, @@ -99,11 +104,12 @@ TrackedResource, UserAssignedIdentity, ValidateBackupResponse, + ValidateBackupResponseProperties, VirtualNetworkSubnetUsageParameter, VirtualNetworkSubnetUsageResult, ) -from ._my_sql_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore AdministratorName, AdministratorType, AdvancedThreatProtectionName, @@ -134,6 +140,7 @@ PrivateEndpointConnectionProvisioningState, PrivateEndpointServiceConnectionStatus, ProvisioningState, + ReplicationMode, ReplicationRole, ResetAllToDefault, ServerSkuTier, @@ -146,36 +153,39 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AdministratorListResult", + "AdministratorProperties", "AdvancedThreatProtection", "AdvancedThreatProtectionForUpdate", - "AdvancedThreatProtectionListResult", + "AdvancedThreatProtectionProperties", + "AdvancedThreatProtectionUpdateProperties", "AzureADAdministrator", "Backup", "BackupAndExportRequest", "BackupAndExportResponse", + "BackupAndExportResponseProperties", "BackupAndExportResponseType", "BackupRequestBase", "BackupSettings", "BackupStoreDetails", - "CapabilitiesListResult", "Capability", "CapabilityProperties", - "CapabilitySetsList", + "CapabilityPropertiesV2", "Configuration", "ConfigurationForBatchUpdate", + "ConfigurationForBatchUpdateProperties", "ConfigurationListForBatchUpdate", "ConfigurationListResult", + "ConfigurationProperties", "DataEncryption", "Database", - "DatabaseListResult", + "DatabaseProperties", "DelegatedSubnetUsage", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "FeatureProperty", "FirewallRule", - "FirewallRuleListResult", + "FirewallRuleProperties", "FullBackupStoreDetails", "GetPrivateDnsZoneSuffixResponse", "HighAvailability", @@ -183,10 +193,11 @@ "ImportFromStorageResponseType", "ImportSourceProperties", "LogFile", - "LogFileListResult", + "LogFileProperties", "Maintenance", - "MaintenanceListResult", "MaintenancePolicy", + "MaintenanceProperties", + "MaintenancePropertiesForUpdate", "MaintenanceUpdate", "MaintenanceWindow", "MySQLServerIdentity", @@ -196,7 +207,6 @@ "Network", "Operation", "OperationDisplay", - "OperationListResult", "OperationProgressResponseType", "OperationProgressResult", "OperationStatusExtendedResult", @@ -204,22 +214,24 @@ "PrivateEndpoint", "PrivateEndpointConnection", "PrivateEndpointConnectionListResult", + "PrivateEndpointConnectionProperties", "PrivateLinkResource", - "PrivateLinkResourceListResult", + "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", "ProxyResource", "Resource", "Server", "ServerBackup", - "ServerBackupListResult", + "ServerBackupProperties", + "ServerBackupPropertiesV2", "ServerBackupV2", - "ServerBackupV2ListResult", "ServerDetachVNetParameter", "ServerEditionCapability", "ServerEditionCapabilityV2", "ServerForUpdate", "ServerGtidSetParameter", - "ServerListResult", + "ServerProperties", + "ServerPropertiesForUpdate", "ServerRestartParameter", "ServerVersionCapability", "ServerVersionCapabilityV2", @@ -231,6 +243,7 @@ "TrackedResource", "UserAssignedIdentity", "ValidateBackupResponse", + "ValidateBackupResponseProperties", "VirtualNetworkSubnetUsageParameter", "VirtualNetworkSubnetUsageResult", "AdministratorName", @@ -263,6 +276,7 @@ "PrivateEndpointConnectionProvisioningState", "PrivateEndpointServiceConnectionStatus", "ProvisioningState", + "ReplicationMode", "ReplicationRole", "ResetAllToDefault", "ServerSkuTier", diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_my_sql_management_client_enums.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_enums.py similarity index 88% rename from sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_my_sql_management_client_enums.py rename to sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_enums.py index 5afe7912ce78..7457af041ba4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_my_sql_management_client_enums.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -11,7 +11,7 @@ class AdministratorName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AdministratorName.""" + """Type of AdministratorName.""" ACTIVE_DIRECTORY = "ActiveDirectory" @@ -23,7 +23,7 @@ class AdministratorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AdvancedThreatProtectionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AdvancedThreatProtectionName.""" + """Type of AdvancedThreatProtectionName.""" DEFAULT = "Default" @@ -54,7 +54,7 @@ class BackupFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): class BackupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """BackupType.""" + """Type of BackupType.""" FULL = "FULL" @@ -75,12 +75,16 @@ class ConfigurationSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): 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): @@ -100,7 +104,7 @@ class DataEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class EnableStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether or not geo redundant backup is enabled.""" + """Enum to indicate whether value is 'Enabled' or 'Disabled'.""" ENABLED = "Enabled" DISABLED = "Disabled" @@ -234,17 +238,24 @@ class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsens """The current provisioning state.""" SUCCEEDED = "Succeeded" + """Connection has been provisioned""" CREATING = "Creating" + """Connection is being created""" DELETING = "Deleting" + """Connection is being deleted""" FAILED = "Failed" + """Connection provisioning has failed""" class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status.""" PENDING = "Pending" + """Connection waiting for approval or rejection""" APPROVED = "Approved" + """Connection approved""" REJECTED = "Rejected" + """Connection Rejected""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -257,6 +268,15 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" +class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The replication Mode.""" + + BINARY_LOG = "BinaryLog" + """Binary log replication""" + REDO_LOG = "RedoLog" + """Redo log replication""" + + class ReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The replication role.""" @@ -297,10 +317,11 @@ class ServerVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): FIVE7 = "5.7" EIGHT0_21 = "8.0.21" + ENUM_8_4 = "8.4" class StorageRedundancyEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The redundant type of the server storage. The parameter is used for server creation.""" + """Enum to indicate whether storage sku value is 'ZoneRedundancy' or 'LocalRedundancy'.""" LOCAL_REDUNDANCY = "LocalRedundancy" ZONE_REDUNDANCY = "ZoneRedundancy" diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py new file mode 100644 index 000000000000..449aabbd4343 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py @@ -0,0 +1,4289 @@ +# 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, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field +from ._enums import ObjectType + +if TYPE_CHECKING: + from .. import models as _models + + +class AdministratorProperties(_Model): + """The properties of an administrator. + + :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" + :vartype administrator_type: str or ~azure.mgmt.mysqlflexibleservers.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 identity_resource_id: The resource id of the identity used for AAD Authentication. + :vartype identity_resource_id: str + """ + + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = rest_field( + name="administratorType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of the sever administrator. \"ActiveDirectory\"""" + 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.""" + identity_resource_id: Optional[str] = rest_field( + name="identityResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource id of the identity used for AAD Authentication.""" + + @overload + def __init__( + self, + *, + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, + login: Optional[str] = None, + sid: Optional[str] = None, + tenant_id: Optional[str] = None, + identity_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 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.mysqlflexibleservers.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.mysqlflexibleservers.models.SystemData + """ + + +class AdvancedThreatProtection(ProxyResource): + """A server's 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.mysqlflexibleservers.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProperties + """ + + properties: Optional["_models.AdvancedThreatProtectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["creation_time", "state", "provisioning_state"] + + @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 AdvancedThreatProtectionForUpdate(_Model): + """Parameters allowed to update advanced threat protection for a server. + + :ivar properties: Resource update properties. + :vartype properties: + ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionUpdateProperties + """ + + properties: Optional["_models.AdvancedThreatProtectionUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource update properties.""" + + __flattened_items = ["state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdvancedThreatProtectionUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 AdvancedThreatProtectionProperties(_Model): + """Properties of an Advanced Threat Protection setting. + + :ivar creation_time: Specifies the UTC creation time of the policy. + :vartype creation_time: ~datetime.datetime + :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: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState + :ivar provisioning_state: Provisioning state of the Threat Protection. Known values are: + "Succeeded", "Updating", "Canceled", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState + """ + + creation_time: Optional[datetime.datetime] = rest_field(name="creationTime", visibility=["read"], format="rfc3339") + """Specifies the UTC creation time of the policy.""" + state: Optional[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. Known values are: + \"Enabled\" and \"Disabled\".""" + provisioning_state: Optional[Union[str, "_models.AdvancedThreatProtectionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the Threat Protection. Known values are: \"Succeeded\", \"Updating\", + \"Canceled\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 AdvancedThreatProtectionUpdateProperties(_Model): + """Properties of Advanced Threat Protection that can be updated. + + :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: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState + """ + + 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: + \"Enabled\" and \"Disabled\".""" + + @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 AzureADAdministrator(ProxyResource): + """Represents a 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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of an administrator. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.AdministratorProperties + """ + + properties: Optional["_models.AdministratorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of an administrator.""" + + __flattened_items = ["administrator_type", "login", "sid", "tenant_id", "identity_resource_id"] + + @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 Backup(_Model): + """Storage Profile properties of a server. + + :ivar backup_retention_days: Backup retention days for the server. + :vartype backup_retention_days: int + :ivar backup_interval_hours: Backup interval hours for the server. + :vartype backup_interval_hours: int + :ivar geo_redundant_backup: Whether or not geo redundant backup is enabled. Known values are: + "Enabled" and "Disabled". + :vartype geo_redundant_backup: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar earliest_restore_date: Earliest restore point creation time (ISO8601 format). + :vartype earliest_restore_date: ~datetime.datetime + """ + + backup_retention_days: Optional[int] = rest_field( + name="backupRetentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup retention days for the server.""" + backup_interval_hours: Optional[int] = rest_field( + name="backupIntervalHours", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup interval hours for the server.""" + geo_redundant_backup: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( + name="geoRedundantBackup", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not geo redundant backup is enabled. Known values are: \"Enabled\" and \"Disabled\".""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """Earliest restore point creation time (ISO8601 format).""" + + @overload + def __init__( + self, + *, + backup_retention_days: Optional[int] = None, + backup_interval_hours: Optional[int] = None, + geo_redundant_backup: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 BackupRequestBase(_Model): + """BackupRequestBase is the base for all backup request. + + :ivar backup_settings: Backup Settings. Required. + :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings + """ + + backup_settings: "_models.BackupSettings" = rest_field( + name="backupSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup Settings. Required.""" + + @overload + def __init__( + self, + *, + backup_settings: "_models.BackupSettings", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 BackupAndExportRequest(BackupRequestBase): + """BackupAndExport API Request. + + :ivar backup_settings: Backup Settings. Required. + :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings + :ivar target_details: Backup Target Store Details. Required. + :vartype target_details: ~azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails + """ + + target_details: "_models.BackupStoreDetails" = rest_field( + name="targetDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup Target Store Details. Required.""" + + @overload + def __init__( + self, + *, + backup_settings: "_models.BackupSettings", + target_details: "_models.BackupStoreDetails", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 BackupAndExportResponse(ProxyResource): + """Represents BackupAndExportAPI Response. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: 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.mysqlflexibleservers.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseProperties + :ivar error: The error object. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :ivar name: The name of the backup and export response. Required. + :vartype name: str + :ivar status: The operation status. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Canceled". + :vartype status: str or ~azure.mgmt.mysqlflexibleservers.models.OperationStatus + :ivar start_time: Start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: Operation progress (0-100). + :vartype percent_complete: float + """ + + properties: Optional["_models.BackupAndExportResponseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + name: str = rest_field(visibility=["read"]) + """The name of the backup and export response. Required.""" + status: Optional[Union[str, "_models.OperationStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The operation status. Known values are: \"Pending\", \"InProgress\", \"Succeeded\", \"Failed\", + \"CancelInProgress\", and \"Canceled\".""" + start_time: Optional[datetime.datetime] = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start time.""" + end_time: Optional[datetime.datetime] = rest_field( + name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """End time.""" + percent_complete: Optional[float] = rest_field( + name="percentComplete", visibility=["read", "create", "update", "delete", "query"] + ) + """Operation progress (0-100).""" + + __flattened_items = ["datasource_size_in_bytes", "data_transferred_in_bytes", "backup_metadata"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.BackupAndExportResponseProperties"] = None, + error: Optional["_models.ErrorDetail"] = None, + status: Optional[Union[str, "_models.OperationStatus"]] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + percent_complete: 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: + _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 BackupAndExportResponseProperties(_Model): + """BackupAndExport Response Properties. + + :ivar datasource_size_in_bytes: Size of datasource in bytes. + :vartype datasource_size_in_bytes: int + :ivar data_transferred_in_bytes: Data transferred in bytes. + :vartype data_transferred_in_bytes: int + :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in + key-value pairs. + :vartype backup_metadata: str + """ + + datasource_size_in_bytes: Optional[int] = rest_field( + name="datasourceSizeInBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Size of datasource in bytes.""" + data_transferred_in_bytes: Optional[int] = rest_field( + name="dataTransferredInBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Data transferred in bytes.""" + backup_metadata: Optional[str] = rest_field( + name="backupMetadata", visibility=["read", "create", "update", "delete", "query"] + ) + """Metadata related to backup to be stored for restoring resource in key-value pairs.""" + + @overload + def __init__( + self, + *, + datasource_size_in_bytes: Optional[int] = None, + data_transferred_in_bytes: Optional[int] = None, + backup_metadata: 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 OperationProgressResponseType(_Model): + """Represents the response properties specific to the operation. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BackupAndExportResponseType, ImportFromStorageResponseType + + :ivar object_type: Identifies the type of source operation. Required. Known values are: + "BackupAndExportResponse" and "ImportFromStorageResponse". + :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType + """ + + __mapping__: dict[str, _Model] = {} + object_type: str = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) + """Identifies the type of source operation. Required. Known values are: + \"BackupAndExportResponse\" and \"ImportFromStorageResponse\".""" + + @overload + def __init__( + self, + *, + object_type: 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 BackupAndExportResponseType(OperationProgressResponseType, discriminator="BackupAndExportResponse"): + """BackupAndExport Response Properties. + + :ivar datasource_size_in_bytes: Size of datasource in bytes. + :vartype datasource_size_in_bytes: int + :ivar data_transferred_in_bytes: Data transferred in bytes. + :vartype data_transferred_in_bytes: int + :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in + key-value pairs. + :vartype backup_metadata: str + :ivar object_type: Identifies the type of source operation. Required. + :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.BACKUP_AND_EXPORT_RESPONSE + """ + + datasource_size_in_bytes: Optional[int] = rest_field( + name="datasourceSizeInBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Size of datasource in bytes.""" + data_transferred_in_bytes: Optional[int] = rest_field( + name="dataTransferredInBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Data transferred in bytes.""" + backup_metadata: Optional[str] = rest_field( + name="backupMetadata", visibility=["read", "create", "update", "delete", "query"] + ) + """Metadata related to backup to be stored for restoring resource in key-value pairs.""" + object_type: Literal[ObjectType.BACKUP_AND_EXPORT_RESPONSE] = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Identifies the type of source operation. Required.""" + + @overload + def __init__( + self, + *, + datasource_size_in_bytes: Optional[int] = None, + data_transferred_in_bytes: Optional[int] = None, + backup_metadata: 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) + self.object_type = ObjectType.BACKUP_AND_EXPORT_RESPONSE # type: ignore + + +class BackupSettings(_Model): + """Backup Settings. + + :ivar backup_name: The name of the backup. Required. + :vartype backup_name: str + :ivar backup_format: Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT + USE). Known values are: "CollatedFormat" and "Raw". + :vartype backup_format: str or ~azure.mgmt.mysqlflexibleservers.models.BackupFormat + """ + + backup_name: str = rest_field(name="backupName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the backup. Required.""" + backup_format: Optional[Union[str, "_models.BackupFormat"]] = rest_field( + name="backupFormat", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT USE). Known values + are: \"CollatedFormat\" and \"Raw\".""" + + @overload + def __init__( + self, + *, + backup_name: str, + backup_format: Optional[Union[str, "_models.BackupFormat"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 BackupStoreDetails(_Model): + """Details about the target where the backup content will be stored. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FullBackupStoreDetails + + :ivar object_type: Type of the specific object - used for deserializing. Required. Default + value is None. + :vartype object_type: str + """ + + __mapping__: dict[str, _Model] = {} + object_type: str = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) + """Type of the specific object - used for deserializing. Required. Default value is None.""" + + @overload + def __init__( + self, + *, + object_type: 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 Capability(ProxyResource): + """Represents a location capability 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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a location capability set. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.CapabilityPropertiesV2 + """ + + properties: Optional["_models.CapabilityPropertiesV2"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a location capability set.""" + + __flattened_items = [ + "supported_geo_backup_regions", + "supported_flexible_server_editions", + "supported_server_versions", + "supported_features", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CapabilityPropertiesV2"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 CapabilityProperties(_Model): + """Location capabilities. + + :ivar zone: zone name. + :vartype zone: str + :ivar supported_ha_mode: Supported high availability mode. + :vartype supported_ha_mode: list[str] + :ivar supported_geo_backup_regions: supported geo backup regions. + :vartype supported_geo_backup_regions: list[str] + :ivar supported_flexible_server_editions: A list of supported flexible server editions. + :vartype supported_flexible_server_editions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability] + """ + + zone: Optional[str] = rest_field(visibility=["read"]) + """zone name.""" + supported_ha_mode: Optional[list[str]] = rest_field(name="supportedHAMode", visibility=["read"]) + """Supported high availability mode.""" + supported_geo_backup_regions: Optional[list[str]] = rest_field( + name="supportedGeoBackupRegions", visibility=["read"] + ) + """supported geo backup regions.""" + supported_flexible_server_editions: Optional[list["_models.ServerEditionCapability"]] = rest_field( + name="supportedFlexibleServerEditions", visibility=["read"] + ) + """A list of supported flexible server editions.""" + + +class CapabilityPropertiesV2(_Model): + """Location capability. + + :ivar supported_geo_backup_regions: supported geo backup regions. + :vartype supported_geo_backup_regions: list[str] + :ivar supported_flexible_server_editions: A list of supported flexible server editions. + :vartype supported_flexible_server_editions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2] + :ivar supported_server_versions: A list of supported server versions. + :vartype supported_server_versions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2] + :ivar supported_features: A list of supported features. + :vartype supported_features: list[~azure.mgmt.mysqlflexibleservers.models.FeatureProperty] + """ + + supported_geo_backup_regions: Optional[list[str]] = rest_field( + name="supportedGeoBackupRegions", visibility=["read"] + ) + """supported geo backup regions.""" + supported_flexible_server_editions: Optional[list["_models.ServerEditionCapabilityV2"]] = rest_field( + name="supportedFlexibleServerEditions", visibility=["read"] + ) + """A list of supported flexible server editions.""" + supported_server_versions: Optional[list["_models.ServerVersionCapabilityV2"]] = rest_field( + name="supportedServerVersions", visibility=["read"] + ) + """A list of supported server versions.""" + supported_features: Optional[list["_models.FeatureProperty"]] = rest_field( + name="supportedFeatures", visibility=["read"] + ) + """A list of supported features.""" + + +class Configuration(ProxyResource): + """Represents a Configuration. + + :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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a configuration. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationProperties + """ + + properties: Optional["_models.ConfigurationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a configuration.""" + + __flattened_items = [ + "value", + "current_value", + "description", + "documentation_link", + "default_value", + "data_type", + "allowed_values", + "source", + "is_read_only", + "is_config_pending_restart", + "is_dynamic_config", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ConfigurationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ConfigurationForBatchUpdate(_Model): + """Represents a Configuration. + + :ivar name: Name of the configuration. + :vartype name: str + :ivar properties: The properties can be updated for a configuration. + :vartype properties: + ~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdateProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the configuration.""" + properties: Optional["_models.ConfigurationForBatchUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties can be updated for a configuration.""" + + __flattened_items = ["value", "source"] + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.ConfigurationForBatchUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ConfigurationForBatchUpdateProperties(_Model): + """The properties can be updated for a configuration. + + :ivar value: Value of the configuration. + :vartype value: str + :ivar source: Source of the configuration. + :vartype source: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the configuration.""" + source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Source of the configuration.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + source: 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 ConfigurationListForBatchUpdate(_Model): + """A list of server configurations to update. + + :ivar value: The list of server configurations. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate] + :ivar reset_all_to_default: Whether to reset all server parameters to default. Known values + are: "True" and "False". + :vartype reset_all_to_default: str or ~azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault + """ + + value: Optional[list["_models.ConfigurationForBatchUpdate"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The list of server configurations.""" + reset_all_to_default: Optional[Union[str, "_models.ResetAllToDefault"]] = rest_field( + name="resetAllToDefault", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to reset all server parameters to default. Known values are: \"True\" and \"False\".""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.ConfigurationForBatchUpdate"]] = None, + reset_all_to_default: Optional[Union[str, "_models.ResetAllToDefault"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ConfigurationListResult(_Model): + """The response of a Configuration list operation. + + :ivar value: The Configuration items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: Optional[list["_models.Configuration"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Configuration items on this page.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """The link to the next page of items.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.Configuration"]] = None, + next_link: 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 ConfigurationProperties(_Model): + """The properties of a configuration. + + :ivar value: Value of the configuration. + :vartype value: str + :ivar current_value: Current value of the configuration. + :vartype current_value: str + :ivar description: Description of the configuration. + :vartype description: str + :ivar documentation_link: The link used to get the document from community or Azure site. + :vartype documentation_link: str + :ivar default_value: Default value of the configuration. + :vartype default_value: str + :ivar data_type: Data type of the configuration. + :vartype data_type: str + :ivar allowed_values: Allowed values of the configuration. + :vartype allowed_values: str + :ivar source: Source of the configuration. Known values are: "system-default" and + "user-override". + :vartype source: str or ~azure.mgmt.mysqlflexibleservers.models.ConfigurationSource + :ivar is_read_only: If is the configuration read only. Known values are: "True" and "False". + :vartype is_read_only: str or ~azure.mgmt.mysqlflexibleservers.models.IsReadOnly + :ivar is_config_pending_restart: If is the configuration pending restart or not. Known values + are: "True" and "False". + :vartype is_config_pending_restart: str or + ~azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart + :ivar is_dynamic_config: If is the configuration dynamic. Known values are: "True" and "False". + :vartype is_dynamic_config: str or ~azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the configuration.""" + current_value: Optional[str] = rest_field( + name="currentValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Current value of the configuration.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of the configuration.""" + documentation_link: Optional[str] = rest_field(name="documentationLink", visibility=["read"]) + """The link used to get the document from community or Azure site.""" + default_value: Optional[str] = rest_field(name="defaultValue", visibility=["read"]) + """Default value of the configuration.""" + data_type: Optional[str] = rest_field(name="dataType", visibility=["read"]) + """Data type of the configuration.""" + allowed_values: Optional[str] = rest_field(name="allowedValues", visibility=["read"]) + """Allowed values of the configuration.""" + source: Optional[Union[str, "_models.ConfigurationSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Source of the configuration. Known values are: \"system-default\" and \"user-override\".""" + is_read_only: Optional[Union[str, "_models.IsReadOnly"]] = rest_field(name="isReadOnly", visibility=["read"]) + """If is the configuration read only. Known values are: \"True\" and \"False\".""" + is_config_pending_restart: Optional[Union[str, "_models.IsConfigPendingRestart"]] = rest_field( + name="isConfigPendingRestart", visibility=["read"] + ) + """If is the configuration pending restart or not. Known values are: \"True\" and \"False\".""" + is_dynamic_config: Optional[Union[str, "_models.IsDynamicConfig"]] = rest_field( + name="isDynamicConfig", visibility=["read"] + ) + """If is the configuration dynamic. Known values are: \"True\" and \"False\".""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + current_value: Optional[str] = None, + source: Optional[Union[str, "_models.ConfigurationSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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(ProxyResource): + """Represents 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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a database. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.DatabaseProperties + """ + + properties: Optional["_models.DatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a database.""" + + __flattened_items = ["charset", "collation"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 DatabaseProperties(_Model): + """The properties of a database. + + :ivar charset: The charset of the database. + :vartype charset: str + :ivar collation: The collation of the database. + :vartype collation: str + """ + + charset: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The charset of the database.""" + collation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The collation of the database.""" + + @overload + def __init__( + self, + *, + charset: Optional[str] = None, + collation: 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 DataEncryption(_Model): + """The date encryption for cmk. + + :ivar primary_user_assigned_identity_id: Primary user identity resource id. + :vartype primary_user_assigned_identity_id: str + :ivar primary_key_uri: Primary key uri. + :vartype primary_key_uri: str + :ivar geo_backup_user_assigned_identity_id: Geo backup user identity resource id as identity + can't cross region, need identity in same region as geo backup. + :vartype geo_backup_user_assigned_identity_id: str + :ivar geo_backup_key_uri: Geo backup key uri as key vault can't cross region, need cmk in same + region as geo backup. + :vartype geo_backup_key_uri: str + :ivar type: The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known + values are: "AzureKeyVault" and "SystemManaged". + :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.DataEncryptionType + """ + + primary_user_assigned_identity_id: Optional[str] = rest_field( + name="primaryUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] + ) + """Primary user identity resource id.""" + primary_key_uri: Optional[str] = rest_field( + name="primaryKeyURI", visibility=["read", "create", "update", "delete", "query"] + ) + """Primary key uri.""" + geo_backup_user_assigned_identity_id: Optional[str] = rest_field( + name="geoBackupUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] + ) + """Geo backup user identity resource id as identity can't cross region, need identity in same + region as geo backup.""" + geo_backup_key_uri: Optional[str] = rest_field( + name="geoBackupKeyURI", visibility=["read", "create", "update", "delete", "query"] + ) + """Geo backup key uri as key vault can't cross region, need cmk in same region as geo backup.""" + type: Optional[Union[str, "_models.DataEncryptionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known values are: + \"AzureKeyVault\" and \"SystemManaged\".""" + + @overload + def __init__( + self, + *, + primary_user_assigned_identity_id: Optional[str] = None, + primary_key_uri: Optional[str] = None, + geo_backup_user_assigned_identity_id: Optional[str] = None, + geo_backup_key_uri: Optional[str] = None, + type: Optional[Union[str, "_models.DataEncryptionType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 DelegatedSubnetUsage(_Model): + """Delegated subnet usage data. + + :ivar subnet_name: name of the subnet. + :vartype subnet_name: str + :ivar usage: Number of used delegated subnets. + :vartype usage: int + """ + + subnet_name: Optional[str] = rest_field(name="subnetName", visibility=["read"]) + """name of the subnet.""" + usage: Optional[int] = rest_field(visibility=["read"]) + """Number of used delegated subnets.""" + + +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.mysqlflexibleservers.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 FeatureProperty(_Model): + """Server version capabilities. + + :ivar feature_name: feature name. + :vartype feature_name: str + :ivar feature_value: feature value. + :vartype feature_value: str + """ + + feature_name: Optional[str] = rest_field(name="featureName", visibility=["read"]) + """feature name.""" + feature_value: Optional[str] = rest_field(name="featureValue", visibility=["read"]) + """feature value.""" + + +class FirewallRule(ProxyResource): + """Represents a server 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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a firewall rule. Required. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.FirewallRuleProperties + """ + + properties: "_models.FirewallRuleProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a firewall rule. Required.""" + + __flattened_items = ["start_ip_address", "end_ip_address"] + + @overload + def __init__( + self, + *, + properties: "_models.FirewallRuleProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 FirewallRuleProperties(_Model): + """The properties of a server firewall rule. + + :ivar start_ip_address: The start IP address of the server firewall rule. Must be IPv4 format. + Required. + :vartype start_ip_address: str + :ivar end_ip_address: The end IP address of the server firewall rule. Must be IPv4 format. + Required. + :vartype end_ip_address: str + """ + + start_ip_address: str = rest_field( + name="startIpAddress", visibility=["read", "create", "update", "delete", "query"] + ) + """The start IP address of the server firewall rule. Must be IPv4 format. Required.""" + end_ip_address: str = rest_field(name="endIpAddress", visibility=["read", "create", "update", "delete", "query"]) + """The end IP address of the server firewall rule. Must be IPv4 format. Required.""" + + @overload + def __init__( + self, + *, + start_ip_address: str, + end_ip_address: 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 FullBackupStoreDetails(BackupStoreDetails, discriminator="FullBackupStoreDetails"): + """FullBackupStoreDetails is used for scenarios where backup data is streamed/copied over to a + storage destination. + + :ivar sas_uri_list: SASUriList of storage containers where backup data is to be + streamed/copied. Required. + :vartype sas_uri_list: list[str] + :ivar object_type: Type of the specific object - used for deserializing. Required. Default + value is "FullBackupStoreDetails". + :vartype object_type: str + """ + + sas_uri_list: list[str] = rest_field(name="sasUriList", visibility=["read", "create", "update", "delete", "query"]) + """SASUriList of storage containers where backup data is to be streamed/copied. Required.""" + object_type: Literal["FullBackupStoreDetails"] = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Type of the specific object - used for deserializing. Required. Default value is + \"FullBackupStoreDetails\".""" + + @overload + def __init__( + self, + *, + sas_uri_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) + self.object_type = "FullBackupStoreDetails" # type: ignore + + +class GetPrivateDnsZoneSuffixResponse(_Model): + """The response of get private dns zone suffix. + + :ivar private_dns_zone_suffix: Represents the private DNS zone suffix. + :vartype private_dns_zone_suffix: str + """ + + private_dns_zone_suffix: Optional[str] = rest_field( + name="privateDnsZoneSuffix", visibility=["read", "create", "update", "delete", "query"] + ) + """Represents the private DNS zone suffix.""" + + @overload + def __init__( + self, + *, + private_dns_zone_suffix: 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 HighAvailability(_Model): + """High availability properties of a server. + + :ivar mode: High availability mode for a server. Known values are: "Disabled", "ZoneRedundant", + and "SameZone". + :vartype mode: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode + :ivar state: The state of server high availability. Known values are: "NotEnabled", + "CreatingStandby", "Healthy", "FailingOver", and "RemovingStandby". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState + :ivar standby_availability_zone: Availability zone of the standby server. + :vartype standby_availability_zone: str + :ivar replication_mode: HA Replication mode for a server. Known values are: "BinaryLog" and + "RedoLog". + :vartype replication_mode: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationMode + """ + + mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """High availability mode for a server. Known values are: \"Disabled\", \"ZoneRedundant\", and + \"SameZone\".""" + state: Optional[Union[str, "_models.HighAvailabilityState"]] = rest_field(visibility=["read"]) + """The state of server high availability. Known values are: \"NotEnabled\", \"CreatingStandby\", + \"Healthy\", \"FailingOver\", and \"RemovingStandby\".""" + standby_availability_zone: Optional[str] = rest_field( + name="standbyAvailabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Availability zone of the standby server.""" + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = rest_field( + name="replicationMode", visibility=["read", "create", "update", "delete", "query"] + ) + """HA Replication mode for a server. Known values are: \"BinaryLog\" and \"RedoLog\".""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = None, + standby_availability_zone: Optional[str] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 HighAvailabilityValidationEstimation(_Model): + """High availability validation properties of a server. + + :ivar estimated_downtime: Estimated seconds of downtime for the deployment. + :vartype estimated_downtime: int + :ivar scheduled_standby_availability_zone: Scheduled Availability zone of the standby server. + :vartype scheduled_standby_availability_zone: str + :ivar expected_standby_availability_zone: Expected Availability zone of the standby server. + :vartype expected_standby_availability_zone: str + """ + + estimated_downtime: Optional[int] = rest_field(name="estimatedDowntime", visibility=["read"]) + """Estimated seconds of downtime for the deployment.""" + scheduled_standby_availability_zone: Optional[str] = rest_field( + name="scheduledStandbyAvailabilityZone", visibility=["read"] + ) + """Scheduled Availability zone of the standby server.""" + expected_standby_availability_zone: Optional[str] = rest_field( + name="expectedStandbyAvailabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Expected Availability zone of the standby server.""" + + @overload + def __init__( + self, + *, + expected_standby_availability_zone: 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 ImportFromStorageResponseType(OperationProgressResponseType, discriminator="ImportFromStorageResponse"): + """ImportFromStorage Response Properties. + + :ivar estimated_completion_time: The estimated time of operation completion. + :vartype estimated_completion_time: ~datetime.datetime + :ivar object_type: Identifies the type of source operation. Required. + :vartype object_type: str or + ~azure.mgmt.mysqlflexibleservers.models.IMPORT_FROM_STORAGE_RESPONSE + """ + + estimated_completion_time: Optional[datetime.datetime] = rest_field( + name="estimatedCompletionTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The estimated time of operation completion.""" + object_type: Literal[ObjectType.IMPORT_FROM_STORAGE_RESPONSE] = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Identifies the type of source operation. Required.""" + + @overload + def __init__( + self, + *, + estimated_completion_time: 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) + self.object_type = ObjectType.IMPORT_FROM_STORAGE_RESPONSE # type: ignore + + +class ImportSourceProperties(_Model): + """Import source related properties. + + :ivar storage_type: Storage type of import source. "AzureBlob" + :vartype storage_type: str or ~azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType + :ivar storage_url: Uri of the import source storage. + :vartype storage_url: str + :ivar sas_token: Sas token for accessing source storage. Read and list permissions are required + for sas token. + :vartype sas_token: str + :ivar data_dir_path: Relative path of data directory in storage. + :vartype data_dir_path: str + """ + + storage_type: Optional[Union[str, "_models.ImportSourceStorageType"]] = rest_field( + name="storageType", visibility=["read", "create"] + ) + """Storage type of import source. \"AzureBlob\"""" + storage_url: Optional[str] = rest_field(name="storageUrl", visibility=["read", "create"]) + """Uri of the import source storage.""" + sas_token: Optional[str] = rest_field(name="sasToken", visibility=["create"]) + """Sas token for accessing source storage. Read and list permissions are required for sas token.""" + data_dir_path: Optional[str] = rest_field(name="dataDirPath", visibility=["read", "create"]) + """Relative path of data directory in storage.""" + + @overload + def __init__( + self, + *, + storage_type: Optional[Union[str, "_models.ImportSourceStorageType"]] = None, + storage_url: Optional[str] = None, + sas_token: Optional[str] = None, + data_dir_path: 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 LogFile(ProxyResource): + """Represents a logFile. + + :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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a logFile. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.LogFileProperties + """ + + properties: Optional["_models.LogFileProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a logFile.""" + + __flattened_items = ["size_in_kb", "created_time", "type", "last_modified_time", "url"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LogFileProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 LogFileProperties(_Model): + """The properties of a logFile. + + :ivar size_in_kb: The size in kb of the logFile. + :vartype size_in_kb: int + :ivar created_time: Creation timestamp of the log file. + :vartype created_time: ~datetime.datetime + :ivar type: Type of the log file. + :vartype type: str + :ivar last_modified_time: Last modified timestamp of the log file. + :vartype last_modified_time: ~datetime.datetime + :ivar url: The url to download the log file from. + :vartype url: str + """ + + size_in_kb: Optional[int] = rest_field(name="sizeInKB", visibility=["read", "create", "update", "delete", "query"]) + """The size in kb of the logFile.""" + created_time: Optional[datetime.datetime] = rest_field( + name="createdTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Creation timestamp of the log file.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Type of the log file.""" + last_modified_time: Optional[datetime.datetime] = rest_field( + name="lastModifiedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Last modified timestamp of the log file.""" + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The url to download the log file from.""" + + @overload + def __init__( + self, + *, + size_in_kb: Optional[int] = None, + created_time: Optional[datetime.datetime] = None, + type: Optional[str] = None, + last_modified_time: Optional[datetime.datetime] = None, + url: 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 Maintenance(ProxyResource): + """Represents a maintenance. + + :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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a maintenance. Required. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceProperties + """ + + properties: "_models.MaintenanceProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of a maintenance. Required.""" + + __flattened_items = [ + "maintenance_type", + "maintenance_state", + "maintenance_start_time", + "maintenance_end_time", + "maintenance_execution_start_time", + "maintenance_execution_end_time", + "maintenance_available_schedule_min_time", + "maintenance_available_schedule_max_time", + "maintenance_title", + "maintenance_description", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + properties: "_models.MaintenanceProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 MaintenancePolicy(_Model): + """Maintenance policy of a server. + + :ivar patch_strategy: The patch strategy of this server. Known values are: "Regular" and + "VirtualCanary". + :vartype patch_strategy: str or ~azure.mgmt.mysqlflexibleservers.models.PatchStrategy + """ + + patch_strategy: Optional[Union[str, "_models.PatchStrategy"]] = rest_field( + name="patchStrategy", visibility=["read", "create", "update", "delete", "query"] + ) + """The patch strategy of this server. Known values are: \"Regular\" and \"VirtualCanary\".""" + + @overload + def __init__( + self, + *, + patch_strategy: Optional[Union[str, "_models.PatchStrategy"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 MaintenanceProperties(_Model): + """The properties of a maintenance resource. + + :ivar maintenance_type: A string defines maintenance type. Known values are: + "RoutineMaintenance", "MinorVersionUpgrade", "SecurityPatches", and "HotFixes". + :vartype maintenance_type: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceType + :ivar maintenance_state: A string describes the maintenance status. Known values are: + "Scheduled", "ReScheduled", "InPreparation", "Processing", "Completed", and "Canceled". + :vartype maintenance_state: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceState + :ivar maintenance_start_time: The start time for a maintenance. + :vartype maintenance_start_time: ~datetime.datetime + :ivar maintenance_end_time: The end time for a maintenance. + :vartype maintenance_end_time: ~datetime.datetime + :ivar maintenance_execution_start_time: The start time for a maintenance execution. + :vartype maintenance_execution_start_time: ~datetime.datetime + :ivar maintenance_execution_end_time: The end time for a maintenance execution. + :vartype maintenance_execution_end_time: ~datetime.datetime + :ivar maintenance_available_schedule_min_time: The min time the maintenance can be rescheduled. + :vartype maintenance_available_schedule_min_time: ~datetime.datetime + :ivar maintenance_available_schedule_max_time: The max time the maintenance can be rescheduled. + :vartype maintenance_available_schedule_max_time: ~datetime.datetime + :ivar maintenance_title: The maintenance title. + :vartype maintenance_title: str + :ivar maintenance_description: The maintenance description. + :vartype maintenance_description: str + :ivar provisioning_state: Provisioning state of the Maintenance. Known values are: "Succeeded", + "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState + """ + + maintenance_type: Optional[Union[str, "_models.MaintenanceType"]] = rest_field( + name="maintenanceType", visibility=["read"] + ) + """A string defines maintenance type. Known values are: \"RoutineMaintenance\", + \"MinorVersionUpgrade\", \"SecurityPatches\", and \"HotFixes\".""" + maintenance_state: Optional[Union[str, "_models.MaintenanceState"]] = rest_field( + name="maintenanceState", visibility=["read"] + ) + """A string describes the maintenance status. Known values are: \"Scheduled\", \"ReScheduled\", + \"InPreparation\", \"Processing\", \"Completed\", and \"Canceled\".""" + maintenance_start_time: Optional[datetime.datetime] = rest_field( + name="maintenanceStartTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The start time for a maintenance.""" + maintenance_end_time: Optional[datetime.datetime] = rest_field( + name="maintenanceEndTime", visibility=["read"], format="rfc3339" + ) + """The end time for a maintenance.""" + maintenance_execution_start_time: Optional[datetime.datetime] = rest_field( + name="maintenanceExecutionStartTime", visibility=["read"], format="rfc3339" + ) + """The start time for a maintenance execution.""" + maintenance_execution_end_time: Optional[datetime.datetime] = rest_field( + name="maintenanceExecutionEndTime", visibility=["read"], format="rfc3339" + ) + """The end time for a maintenance execution.""" + maintenance_available_schedule_min_time: Optional[datetime.datetime] = rest_field( + name="maintenanceAvailableScheduleMinTime", visibility=["read"], format="rfc3339" + ) + """The min time the maintenance can be rescheduled.""" + maintenance_available_schedule_max_time: Optional[datetime.datetime] = rest_field( + name="maintenanceAvailableScheduleMaxTime", visibility=["read"], format="rfc3339" + ) + """The max time the maintenance can be rescheduled.""" + maintenance_title: Optional[str] = rest_field(name="maintenanceTitle", visibility=["read"]) + """The maintenance title.""" + maintenance_description: Optional[str] = rest_field(name="maintenanceDescription", visibility=["read"]) + """The maintenance description.""" + provisioning_state: Optional[Union[str, "_models.MaintenanceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the Maintenance. Known values are: \"Succeeded\", \"Creating\", + \"Deleting\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + maintenance_start_time: 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 MaintenancePropertiesForUpdate(_Model): + """The properties of a maintenance update parameter. + + :ivar maintenance_start_time: The start time for a maintenance. + :vartype maintenance_start_time: ~datetime.datetime + """ + + maintenance_start_time: Optional[datetime.datetime] = rest_field( + name="maintenanceStartTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The start time for a maintenance.""" + + @overload + def __init__( + self, + *, + maintenance_start_time: 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 MaintenanceUpdate(_Model): + """Represents a maintenance update parameter. + + :ivar properties: The properties of a maintenance update parameter. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePropertiesForUpdate + """ + + properties: Optional["_models.MaintenancePropertiesForUpdate"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a maintenance update parameter.""" + + __flattened_items = ["maintenance_start_time"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.MaintenancePropertiesForUpdate"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 MaintenanceWindow(_Model): + """Maintenance window of a server. + + :ivar custom_window: indicates whether custom window is enabled or disabled. + :vartype custom_window: str + :ivar start_hour: start hour for maintenance window. + :vartype start_hour: int + :ivar start_minute: start minute for maintenance window. + :vartype start_minute: int + :ivar day_of_week: day of week for maintenance window. + :vartype day_of_week: int + :ivar batch_of_maintenance: The batch of maintenance when enabled the custom managed + maintenance window of a server. Known values are: "Default", "Batch1", and "Batch2". + :vartype batch_of_maintenance: str or + ~azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance + """ + + custom_window: Optional[str] = rest_field( + name="customWindow", visibility=["read", "create", "update", "delete", "query"] + ) + """indicates whether custom window is enabled or disabled.""" + start_hour: Optional[int] = rest_field(name="startHour", visibility=["read", "create", "update", "delete", "query"]) + """start hour for maintenance window.""" + start_minute: Optional[int] = rest_field( + name="startMinute", visibility=["read", "create", "update", "delete", "query"] + ) + """start minute for maintenance window.""" + day_of_week: Optional[int] = rest_field( + name="dayOfWeek", visibility=["read", "create", "update", "delete", "query"] + ) + """day of week for maintenance window.""" + batch_of_maintenance: Optional[Union[str, "_models.BatchOfMaintenance"]] = rest_field( + name="batchOfMaintenance", visibility=["read", "create", "update", "delete", "query"] + ) + """The batch of maintenance when enabled the custom managed maintenance window of a server. Known + values are: \"Default\", \"Batch1\", and \"Batch2\".""" + + @overload + def __init__( + self, + *, + custom_window: Optional[str] = None, + start_hour: Optional[int] = None, + start_minute: Optional[int] = None, + day_of_week: Optional[int] = None, + batch_of_maintenance: Optional[Union[str, "_models.BatchOfMaintenance"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 MySQLServerIdentity(_Model): + """Properties to configure Identity for Bring your Own Keys. + + :ivar principal_id: ObjectId from the KeyVault. + :vartype principal_id: str + :ivar tenant_id: TenantId from the KeyVault. + :vartype tenant_id: str + :ivar type: Type of managed service identity. "UserAssigned" + :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType + :ivar user_assigned_identities: Metadata of user assigned identity. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity] + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """ObjectId from the KeyVault.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """TenantId from the KeyVault.""" + type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Type of managed service identity. \"UserAssigned\"""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """Metadata of user assigned identity.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 MySQLServerSku(_Model): + """Billing information related properties of a server. + + :ivar name: The name of the sku, e.g. Standard_D32s_v3. Required. + :vartype name: str + :ivar tier: The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: + "Burstable", "GeneralPurpose", and "MemoryOptimized". + :vartype tier: str or ~azure.mgmt.mysqlflexibleservers.models.ServerSkuTier + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the sku, e.g. Standard_D32s_v3. Required.""" + tier: Union[str, "_models.ServerSkuTier"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: \"Burstable\", + \"GeneralPurpose\", and \"MemoryOptimized\".""" + + @overload + def __init__( + self, + *, + name: str, + tier: Union[str, "_models.ServerSkuTier"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 NameAvailability(_Model): + """Represents a resource name availability. + + :ivar message: Error Message. + :vartype message: str + :ivar name_available: Indicates whether the resource name is available. + :vartype name_available: bool + :ivar reason: Reason for name being unavailable. + :vartype reason: str + """ + + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Error Message.""" + name_available: Optional[bool] = rest_field( + name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the resource name is available.""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Reason for name being unavailable.""" + + @overload + def __init__( + self, + *, + message: Optional[str] = None, + name_available: Optional[bool] = None, + 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 NameAvailabilityRequest(_Model): + """Request from client to check resource name availability. + + :ivar name: Resource name to verify. Required. + :vartype name: str + :ivar type: Resource type used for verification. + :vartype type: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource name to verify. Required.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource type used for verification.""" + + @overload + def __init__( + self, + *, + name: str, + 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 Network(_Model): + """Network related properties of a server. + + :ivar public_network_access: Whether or not public network access is allowed for this server. + Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar delegated_subnet_resource_id: Delegated subnet resource id used to setup vnet for a + server. + :vartype delegated_subnet_resource_id: str + :ivar private_dns_zone_resource_id: Private DNS zone resource id. + :vartype private_dns_zone_resource_id: str + """ + + public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not public network access is allowed for this server. Value is 'Disabled' when + server has VNet integration. Known values are: \"Enabled\" and \"Disabled\".""" + delegated_subnet_resource_id: Optional[str] = rest_field( + name="delegatedSubnetResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Delegated subnet resource id used to setup vnet for a server.""" + private_dns_zone_resource_id: Optional[str] = rest_field( + name="privateDnsZoneResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Private DNS zone resource id.""" + + @overload + def __init__( + self, + *, + public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + delegated_subnet_resource_id: Optional[str] = None, + private_dns_zone_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 Operation(_Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.mysqlflexibleservers.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.mysqlflexibleservers.models.Origin + :ivar properties: Additional descriptions for the operation. + :vartype properties: dict[str, any] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + \"Microsoft.Compute/virtualMachines/write\", + \"Microsoft.Compute/virtualMachines/capture/action\".""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Localized display information for this particular operation.""" + origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and + \"user,system\".""" + properties: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Additional descriptions for the operation.""" + + @overload + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + properties: Optional[dict[str, Any]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 OperationDisplay(_Model): + """Display metadata associated with the operation. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring + Insights\" or \"Microsoft Compute\".""" + resource: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly name of the resource type related to this operation. E.g. \"Virtual + Machines\" or \"Job Schedule Collections\".""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create + or Update Virtual Machine\", \"Restart Virtual Machine\".""" + description: Optional[str] = rest_field(visibility=["read"]) + """The short, localized friendly description of the operation; suitable for tool tips and detailed + views.""" + + +class OperationStatusResult(_Model): + """The current status of an async operation. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified ID for the async operation.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the async operation.""" + status: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation status. Required.""" + percent_complete: Optional[float] = rest_field( + name="percentComplete", visibility=["read", "create", "update", "delete", "query"] + ) + """Percent of the operation that is complete.""" + start_time: Optional[datetime.datetime] = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The start time of the operation.""" + end_time: Optional[datetime.datetime] = rest_field( + name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The end time of the operation.""" + operations: Optional[list["_models.OperationStatusResult"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The operations list.""" + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If present, details of the operation error.""" + resource_id: Optional[str] = rest_field(name="resourceId", visibility=["read"]) + """Fully qualified ID of the resource against which the original async operation was started.""" + + @overload + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[list["_models.OperationStatusResult"]] = None, + 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 OperationProgressResult(OperationStatusResult): + """Represents Operation Results API Response. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + :ivar properties: The response properties specific to the operation. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType + """ + + properties: Optional["_models.OperationProgressResponseType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The response properties specific to the operation.""" + + @overload + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[list["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + properties: Optional["_models.OperationProgressResponseType"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 OperationStatusExtendedResult(OperationStatusResult): + """Represents Operation Results API Response. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + :ivar properties: The extended properties of Operation Results. + :vartype properties: dict[str, any] + """ + + properties: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The extended properties of Operation Results.""" + + @overload + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[list["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + properties: Optional[dict[str, Any]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 PrivateEndpoint(_Model): + """The private endpoint resource. + + :ivar id: The resource identifier of the private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The resource identifier of the private endpoint.""" + + +class PrivateEndpointConnection(Resource): + """A private endpoint connection 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.mysqlflexibleservers.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProperties + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["group_ids", "private_endpoint", "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 PrivateEndpointConnectionListResult(_Model): + """The response of a PrivateEndpointConnection list operation. + + :ivar value: The PrivateEndpointConnection items on this page. Required. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: list["_models.PrivateEndpointConnection"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The PrivateEndpointConnection items on this page. Required.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """The link to the next page of items.""" + + @overload + def __init__( + self, + *, + value: list["_models.PrivateEndpointConnection"], + next_link: 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 PrivateEndpointConnectionProperties(_Model): + """Properties of the private endpoint connection. + + :ivar group_ids: The group ids for the private endpoint resource. + :vartype group_ids: list[str] + :ivar private_endpoint: The private endpoint resource. + :vartype private_endpoint: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState + """ + + group_ids: Optional[list[str]] = rest_field(name="groupIds", visibility=["read"]) + """The group ids for the private endpoint resource.""" + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The private endpoint resource.""" + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of information about the state of the connection between service consumer and + provider. Required.""" + provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The provisioning state of the private endpoint connection resource. Known values are: + \"Succeeded\", \"Creating\", \"Deleting\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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(Resource): + """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.mysqlflexibleservers.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceProperties + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 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 private link DNS zone name. + :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", "create", "update", "delete", "query"] + ) + """The private link resource private link DNS zone name.""" + + @overload + def __init__( + self, + *, + required_zone_names: 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 PrivateLinkServiceConnectionState(_Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or + ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", and \"Rejected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval/rejection of the connection.""" + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: 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 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.mysqlflexibleservers.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 Server(TrackedResource): + """Represents 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.mysqlflexibleservers.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: Properties of the server. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerProperties + :ivar identity: The cmk identity for the server. + :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity + :ivar sku: The SKU (pricing tier) of the server. + :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku + """ + + properties: Optional["_models.ServerProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the server.""" + identity: Optional["_models.MySQLServerIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The cmk identity for the server.""" + sku: Optional["_models.MySQLServerSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU (pricing tier) of the server.""" + + __flattened_items = [ + "administrator_login", + "administrator_login_password", + "version", + "full_version", + "availability_zone", + "create_mode", + "source_server_resource_id", + "restore_point_in_time", + "replication_role", + "replica_capacity", + "data_encryption", + "state", + "fully_qualified_domain_name", + "database_port", + "storage", + "backup", + "high_availability", + "network", + "private_endpoint_connections", + "maintenance_policy", + "maintenance_window", + "import_source_properties", + "lower_case_table_names", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ServerProperties"] = None, + identity: Optional["_models.MySQLServerIdentity"] = None, + sku: Optional["_models.MySQLServerSku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ServerBackup(ProxyResource): + """Server backup properties. + + :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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a server backup. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupProperties + """ + + properties: Optional["_models.ServerBackupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a server backup.""" + + __flattened_items = ["backup_type", "completed_time", "source"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerBackupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ServerBackupProperties(_Model): + """The properties of a server backup. + + :ivar backup_type: Backup type. + :vartype backup_type: str + :ivar completed_time: Backup completed time (ISO8601 format). + :vartype completed_time: ~datetime.datetime + :ivar source: Backup source. + :vartype source: str + """ + + backup_type: Optional[str] = rest_field( + name="backupType", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup type.""" + completed_time: Optional[datetime.datetime] = rest_field( + name="completedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Backup completed time (ISO8601 format).""" + source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backup source.""" + + @overload + def __init__( + self, + *, + backup_type: Optional[str] = None, + completed_time: Optional[datetime.datetime] = None, + source: 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 ServerBackupPropertiesV2(_Model): + """The properties of a server backup. + + :ivar backup_name_v2: Backup name. + :vartype backup_name_v2: str + :ivar backup_type: "FULL" + :vartype backup_type: str or ~azure.mgmt.mysqlflexibleservers.models.BackupType + :ivar completed_time: Backup completed time (ISO8601 format). + :vartype completed_time: ~datetime.datetime + :ivar source: Backup source. + :vartype source: str + :ivar provisioning_state: The provisioning state of backup resource. Known values are: + "Succeeded", "Creating", "Deleting", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.mysqlflexibleservers.models.ProvisioningState + """ + + backup_name_v2: Optional[str] = rest_field( + name="backupNameV2", visibility=["read", "create", "update", "delete", "query"] + ) + """Backup name.""" + backup_type: Optional[Union[str, "_models.BackupType"]] = rest_field( + name="backupType", visibility=["read", "create", "update", "delete", "query"] + ) + """\"FULL\"""" + completed_time: Optional[datetime.datetime] = rest_field( + name="completedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Backup completed time (ISO8601 format).""" + source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backup source.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The provisioning state of backup resource. Known values are: \"Succeeded\", \"Creating\", + \"Deleting\", \"Failed\", and \"Canceled\".""" + + @overload + def __init__( + self, + *, + backup_name_v2: Optional[str] = None, + backup_type: Optional[Union[str, "_models.BackupType"]] = None, + completed_time: Optional[datetime.datetime] = None, + source: 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 ServerBackupV2(ProxyResource): + """Server backup properties. + + :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.mysqlflexibleservers.models.SystemData + :ivar properties: The properties of a server backup. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupPropertiesV2 + """ + + properties: Optional["_models.ServerBackupPropertiesV2"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a server backup.""" + + __flattened_items = ["backup_name_v2", "backup_type", "completed_time", "source", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerBackupPropertiesV2"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ServerDetachVNetParameter(_Model): + """Parameters to detach Vnet. + + :ivar public_network_access: Whether or not public network access is allowed for this server. + Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + """ + + public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not public network access is allowed for this server. Value is 'Disabled' when + server has VNet integration. Known values are: \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ServerEditionCapability(_Model): + """Server edition capabilities. + + :ivar name: Server edition name. + :vartype name: str + :ivar supported_storage_editions: A list of supported storage editions. + :vartype supported_storage_editions: + list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] + :ivar supported_server_versions: A list of supported server versions. + :vartype supported_server_versions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Server edition name.""" + supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = rest_field( + name="supportedStorageEditions", visibility=["read"] + ) + """A list of supported storage editions.""" + supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = rest_field( + name="supportedServerVersions", visibility=["read"] + ) + """A list of supported server versions.""" + + +class ServerEditionCapabilityV2(_Model): + """Server edition capabilities. + + :ivar name: Server edition name. + :vartype name: str + :ivar default_sku: Default Sku name. + :vartype default_sku: str + :ivar default_storage_size: Default storage size. + :vartype default_storage_size: int + :ivar supported_storage_editions: A list of supported storage editions. + :vartype supported_storage_editions: + list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] + :ivar supported_skus: A list of supported Skus. + :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Server edition name.""" + default_sku: Optional[str] = rest_field(name="defaultSku", visibility=["read"]) + """Default Sku name.""" + default_storage_size: Optional[int] = rest_field(name="defaultStorageSize", visibility=["read"]) + """Default storage size.""" + supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = rest_field( + name="supportedStorageEditions", visibility=["read"] + ) + """A list of supported storage editions.""" + supported_skus: Optional[list["_models.SkuCapabilityV2"]] = rest_field(name="supportedSkus", visibility=["read"]) + """A list of supported Skus.""" + + +class ServerForUpdate(_Model): + """Parameters allowed to update for a server. + + :ivar identity: The cmk identity for the server. + :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity + :ivar sku: The SKU (pricing tier) of the server. + :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku + :ivar properties: The properties that can be updated for a server. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerPropertiesForUpdate + :ivar tags: Application-specific metadata in the form of key-value pairs. + :vartype tags: dict[str, str] + """ + + identity: Optional["_models.MySQLServerIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The cmk identity for the server.""" + sku: Optional["_models.MySQLServerSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU (pricing tier) of the server.""" + properties: Optional["_models.ServerPropertiesForUpdate"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties that can be updated for a server.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Application-specific metadata in the form of key-value pairs.""" + + __flattened_items = [ + "administrator_login_password", + "version", + "storage", + "backup", + "high_availability", + "maintenance_policy", + "maintenance_window", + "replication_role", + "data_encryption", + "network", + ] + + @overload + def __init__( + self, + *, + identity: Optional["_models.MySQLServerIdentity"] = None, + sku: Optional["_models.MySQLServerSku"] = None, + properties: Optional["_models.ServerPropertiesForUpdate"] = 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 ServerGtidSetParameter(_Model): + """Server Gtid set parameters: Replication with Global Transaction Identifiers. + + :ivar gtid_set: The Gtid set of server. + :vartype gtid_set: str + """ + + gtid_set: Optional[str] = rest_field(name="gtidSet", visibility=["read", "create", "update", "delete", "query"]) + """The Gtid set of server.""" + + @overload + def __init__( + self, + *, + gtid_set: 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 ServerProperties(_Model): + """The properties of a server. + + :ivar administrator_login: The administrator's login name of a server. Can only be specified + when the server is being created (and is required for creation). + :vartype administrator_login: str + :ivar administrator_login_password: The password of the administrator login (required for + server creation). + :vartype administrator_login_password: str + :ivar version: Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL + 5.7. Known values are: "5.7", "8.0.21", and "8.4". + :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion + :ivar full_version: Major version and actual engine version. + :vartype full_version: str + :ivar availability_zone: availability Zone information of the server. + :vartype availability_zone: str + :ivar create_mode: The mode to create a new MySQL server. Known values are: "Default", + "PointInTimeRestore", "Replica", and "GeoRestore". + :vartype create_mode: str or ~azure.mgmt.mysqlflexibleservers.models.CreateMode + :ivar source_server_resource_id: The source MySQL server id. + :vartype source_server_resource_id: str + :ivar restore_point_in_time: Restore point creation time (ISO8601 format), specifying the time + to restore from. + :vartype restore_point_in_time: ~datetime.datetime + :ivar replication_role: The replication role. Known values are: "None", "Source", and + "Replica". + :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole + :ivar replica_capacity: The maximum number of replicas that a primary server can have. + :vartype replica_capacity: int + :ivar data_encryption: The Data Encryption for CMK. + :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption + :ivar state: The state of a server. Known values are: "Ready", "Dropping", "Disabled", + "Starting", "Stopping", "Stopped", and "Updating". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.ServerState + :ivar fully_qualified_domain_name: The fully qualified domain name of a server. + :vartype fully_qualified_domain_name: str + :ivar database_port: The server database port. Can only be specified when the server is being + created. + :vartype database_port: int + :ivar storage: Storage related properties of a server. + :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage + :ivar backup: Backup related properties of a server. + :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup + :ivar high_availability: High availability related properties of a server. + :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability + :ivar network: Network related properties of a server. + :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network + :ivar private_endpoint_connections: PrivateEndpointConnections related properties of a server. + :vartype private_endpoint_connections: + list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] + :ivar maintenance_policy: Maintenance policy of a server. + :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy + :ivar maintenance_window: Maintenance window of a server. Known issue: cannot be set during + server creation or updated with other properties during server update; must be updated + separately. + :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow + :ivar import_source_properties: Source properties for import from storage. + :vartype import_source_properties: + ~azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties + :ivar lower_case_table_names: The mysql parameter lower_case_table_names. Can only be specified + when the server is being created. Allowed values 1 or 2. + :vartype lower_case_table_names: int + """ + + administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read", "create"]) + """The administrator's login name of a server. Can only be specified when the server is being + created (and is required for creation).""" + administrator_login_password: Optional[str] = rest_field( + name="administratorLoginPassword", visibility=["create", "update"] + ) + """The password of the administrator login (required for server creation).""" + version: Optional[Union[str, "_models.ServerVersion"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL 5.7. Known values + are: \"5.7\", \"8.0.21\", and \"8.4\".""" + full_version: Optional[str] = rest_field(name="fullVersion", visibility=["read"]) + """Major version and actual engine version.""" + availability_zone: Optional[str] = rest_field(name="availabilityZone", visibility=["read", "create"]) + """availability Zone information of the server.""" + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field(name="createMode", visibility=["create"]) + """The mode to create a new MySQL server. Known values are: \"Default\", \"PointInTimeRestore\", + \"Replica\", and \"GeoRestore\".""" + source_server_resource_id: Optional[str] = rest_field(name="sourceServerResourceId", visibility=["read", "create"]) + """The source MySQL server id.""" + restore_point_in_time: Optional[datetime.datetime] = rest_field( + name="restorePointInTime", visibility=["create"], format="rfc3339" + ) + """Restore point creation time (ISO8601 format), specifying the time to restore from.""" + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read", "create", "update", "delete", "query"] + ) + """The replication role. Known values are: \"None\", \"Source\", and \"Replica\".""" + replica_capacity: Optional[int] = rest_field(name="replicaCapacity", visibility=["read"]) + """The maximum number of replicas that a primary server can have.""" + data_encryption: Optional["_models.DataEncryption"] = rest_field( + name="dataEncryption", visibility=["read", "create", "update", "delete", "query"] + ) + """The Data Encryption for CMK.""" + state: Optional[Union[str, "_models.ServerState"]] = rest_field(visibility=["read"]) + """The state of a server. Known values are: \"Ready\", \"Dropping\", \"Disabled\", \"Starting\", + \"Stopping\", \"Stopped\", and \"Updating\".""" + fully_qualified_domain_name: Optional[str] = rest_field(name="fullyQualifiedDomainName", visibility=["read"]) + """The fully qualified domain name of a server.""" + database_port: Optional[int] = rest_field(name="databasePort", visibility=["read", "create"]) + """The server database port. Can only be specified when the server is being created.""" + storage: Optional["_models.Storage"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Storage related properties of a server.""" + backup: Optional["_models.Backup"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backup related properties of a server.""" + high_availability: Optional["_models.HighAvailability"] = rest_field( + name="highAvailability", visibility=["read", "create", "update", "delete", "query"] + ) + """High availability related properties of a server.""" + network: Optional["_models.Network"] = rest_field(visibility=["read", "create"]) + """Network related properties of a server.""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """PrivateEndpointConnections related properties of a server.""" + maintenance_policy: Optional["_models.MaintenancePolicy"] = rest_field( + name="maintenancePolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Maintenance policy of a server.""" + maintenance_window: Optional["_models.MaintenanceWindow"] = rest_field( + name="maintenanceWindow", visibility=["read", "update"] + ) + """Maintenance window of a server. Known issue: cannot be set during server creation or updated + with other properties during server update; must be updated separately.""" + import_source_properties: Optional["_models.ImportSourceProperties"] = rest_field( + name="importSourceProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Source properties for import from storage.""" + lower_case_table_names: Optional[int] = rest_field(name="lowerCaseTableNames", visibility=["read", "create"]) + """The mysql parameter lower_case_table_names. Can only be specified when the server is being + created. Allowed values 1 or 2.""" + + @overload + def __init__( + self, + *, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + version: Optional[Union[str, "_models.ServerVersion"]] = None, + availability_zone: Optional[str] = None, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + source_server_resource_id: Optional[str] = None, + restore_point_in_time: Optional[datetime.datetime] = None, + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, + data_encryption: Optional["_models.DataEncryption"] = None, + database_port: Optional[int] = None, + storage: Optional["_models.Storage"] = None, + backup: Optional["_models.Backup"] = None, + high_availability: Optional["_models.HighAvailability"] = None, + network: Optional["_models.Network"] = None, + maintenance_policy: Optional["_models.MaintenancePolicy"] = None, + maintenance_window: Optional["_models.MaintenanceWindow"] = None, + import_source_properties: Optional["_models.ImportSourceProperties"] = None, + lower_case_table_names: 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 ServerPropertiesForUpdate(_Model): + """The properties that can be updated for a server. + + :ivar administrator_login_password: The password of the administrator login. + :vartype administrator_login_password: str + :ivar version: Server version. Known values are: "5.7", "8.0.21", and "8.4". + :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion + :ivar storage: Storage related properties of a server. + :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage + :ivar backup: Backup related properties of a server. + :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup + :ivar high_availability: High availability related properties of a server. + :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability + :ivar maintenance_policy: Maintenance policy of a server. + :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy + :ivar maintenance_window: Maintenance window of a server. + :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow + :ivar replication_role: The replication role of the server. Known values are: "None", "Source", + and "Replica". + :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole + :ivar data_encryption: The Data Encryption for CMK. + :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption + :ivar network: Network related properties of a server. + :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network + """ + + administrator_login_password: Optional[str] = rest_field( + name="administratorLoginPassword", visibility=["read", "create", "update", "delete", "query"] + ) + """The password of the administrator login.""" + version: Optional[Union[str, "_models.ServerVersion"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Server version. Known values are: \"5.7\", \"8.0.21\", and \"8.4\".""" + storage: Optional["_models.Storage"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Storage related properties of a server.""" + backup: Optional["_models.Backup"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backup related properties of a server.""" + high_availability: Optional["_models.HighAvailability"] = rest_field( + name="highAvailability", visibility=["read", "create", "update", "delete", "query"] + ) + """High availability related properties of a server.""" + maintenance_policy: Optional["_models.MaintenancePolicy"] = rest_field( + name="maintenancePolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Maintenance policy of a server.""" + maintenance_window: Optional["_models.MaintenanceWindow"] = rest_field( + name="maintenanceWindow", visibility=["read", "create", "update", "delete", "query"] + ) + """Maintenance window of a server.""" + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read", "create", "update", "delete", "query"] + ) + """The replication role of the server. Known values are: \"None\", \"Source\", and \"Replica\".""" + data_encryption: Optional["_models.DataEncryption"] = rest_field( + name="dataEncryption", visibility=["read", "create", "update", "delete", "query"] + ) + """The Data Encryption for CMK.""" + network: Optional["_models.Network"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Network related properties of a server.""" + + @overload + def __init__( + self, + *, + administrator_login_password: Optional[str] = None, + version: Optional[Union[str, "_models.ServerVersion"]] = None, + storage: Optional["_models.Storage"] = None, + backup: Optional["_models.Backup"] = None, + high_availability: Optional["_models.HighAvailability"] = None, + maintenance_policy: Optional["_models.MaintenancePolicy"] = None, + maintenance_window: Optional["_models.MaintenanceWindow"] = None, + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, + data_encryption: Optional["_models.DataEncryption"] = None, + network: Optional["_models.Network"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ServerRestartParameter(_Model): + """Server restart parameters. + + :ivar restart_with_failover: Whether or not failover to standby server when restarting a server + with high availability enabled. Known values are: "Enabled" and "Disabled". + :vartype restart_with_failover: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar max_failover_seconds: The maximum allowed failover time in seconds. + :vartype max_failover_seconds: int + """ + + restart_with_failover: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( + name="restartWithFailover", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not failover to standby server when restarting a server with high availability + enabled. Known values are: \"Enabled\" and \"Disabled\".""" + max_failover_seconds: Optional[int] = rest_field( + name="maxFailoverSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum allowed failover time in seconds.""" + + @overload + def __init__( + self, + *, + restart_with_failover: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + max_failover_seconds: 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 ServerVersionCapability(_Model): + """Server version capabilities. + + :ivar name: server version. + :vartype name: str + :ivar supported_skus: A list of supported Skus. + :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapability] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """server version.""" + supported_skus: Optional[list["_models.SkuCapability"]] = rest_field(name="supportedSkus", visibility=["read"]) + """A list of supported Skus.""" + + +class ServerVersionCapabilityV2(_Model): + """Server version capabilities. + + :ivar name: server version. + :vartype name: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """server version.""" + + +class SkuCapability(_Model): + """Sku capability. + + :ivar name: vCore name. + :vartype name: str + :ivar v_cores: supported vCores. + :vartype v_cores: int + :ivar supported_iops: supported IOPS. + :vartype supported_iops: int + :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. + :vartype supported_memory_per_v_core_mb: int + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """vCore name.""" + v_cores: Optional[int] = rest_field(name="vCores", visibility=["read"]) + """supported vCores.""" + supported_iops: Optional[int] = rest_field(name="supportedIops", visibility=["read"]) + """supported IOPS.""" + supported_memory_per_v_core_mb: Optional[int] = rest_field(name="supportedMemoryPerVCoreMB", visibility=["read"]) + """supported memory per vCore in MB.""" + + +class SkuCapabilityV2(_Model): + """Sku capability. + + :ivar name: vCore name. + :vartype name: str + :ivar v_cores: supported vCores. + :vartype v_cores: int + :ivar supported_iops: supported IOPS. + :vartype supported_iops: int + :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. + :vartype supported_memory_per_v_core_mb: int + :ivar supported_zones: Supported zones. + :vartype supported_zones: list[str] + :ivar supported_ha_mode: Supported high availability mode. + :vartype supported_ha_mode: list[str] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """vCore name.""" + v_cores: Optional[int] = rest_field(name="vCores", visibility=["read"]) + """supported vCores.""" + supported_iops: Optional[int] = rest_field(name="supportedIops", visibility=["read"]) + """supported IOPS.""" + supported_memory_per_v_core_mb: Optional[int] = rest_field(name="supportedMemoryPerVCoreMB", visibility=["read"]) + """supported memory per vCore in MB.""" + supported_zones: Optional[list[str]] = rest_field(name="supportedZones", visibility=["read"]) + """Supported zones.""" + supported_ha_mode: Optional[list[str]] = rest_field(name="supportedHAMode", visibility=["read"]) + """Supported high availability mode.""" + + +class Storage(_Model): + """Storage Profile properties of a server. + + :ivar storage_size_gb: Max storage size allowed for a server. + :vartype storage_size_gb: int + :ivar iops: Storage IOPS for a server. + :vartype iops: int + :ivar auto_grow: Enable Storage Auto Grow or not. Known values are: "Enabled" and "Disabled". + :vartype auto_grow: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar log_on_disk: Enable Log On Disk or not. Known values are: "Enabled" and "Disabled". + :vartype log_on_disk: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar storage_sku: The sku name of the server storage. + :vartype storage_sku: str + :ivar auto_io_scaling: Enable IO Auto Scaling or not. Known values are: "Enabled" and + "Disabled". + :vartype auto_io_scaling: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar storage_redundancy: The redundant type of the server storage. The parameter is used for + server creation. Known values are: "LocalRedundancy" and "ZoneRedundancy". + :vartype storage_redundancy: str or + ~azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum + """ + + storage_size_gb: Optional[int] = rest_field( + name="storageSizeGB", visibility=["read", "create", "update", "delete", "query"] + ) + """Max storage size allowed for a server.""" + iops: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Storage IOPS for a server.""" + auto_grow: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( + name="autoGrow", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable Storage Auto Grow or not. Known values are: \"Enabled\" and \"Disabled\".""" + log_on_disk: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( + name="logOnDisk", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable Log On Disk or not. Known values are: \"Enabled\" and \"Disabled\".""" + storage_sku: Optional[str] = rest_field(name="storageSku", visibility=["read"]) + """The sku name of the server storage.""" + auto_io_scaling: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( + name="autoIoScaling", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable IO Auto Scaling or not. Known values are: \"Enabled\" and \"Disabled\".""" + storage_redundancy: Optional[Union[str, "_models.StorageRedundancyEnum"]] = rest_field( + name="storageRedundancy", visibility=["read", "create"] + ) + """The redundant type of the server storage. The parameter is used for server creation. Known + values are: \"LocalRedundancy\" and \"ZoneRedundancy\".""" + + @overload + def __init__( + self, + *, + storage_size_gb: Optional[int] = None, + iops: Optional[int] = None, + auto_grow: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + log_on_disk: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + auto_io_scaling: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + storage_redundancy: Optional[Union[str, "_models.StorageRedundancyEnum"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 StorageEditionCapability(_Model): + """storage edition capability. + + :ivar name: storage edition name. + :vartype name: str + :ivar min_storage_size: The minimal supported storage size. + :vartype min_storage_size: int + :ivar max_storage_size: The maximum supported storage size. + :vartype max_storage_size: int + :ivar min_backup_retention_days: Minimal backup retention days. + :vartype min_backup_retention_days: int + :ivar max_backup_retention_days: Maximum backup retention days. + :vartype max_backup_retention_days: int + :ivar min_backup_interval_hours: Minimal backup interval hours. + :vartype min_backup_interval_hours: int + :ivar max_backup_interval_hours: Maximum backup interval hours. + :vartype max_backup_interval_hours: int + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """storage edition name.""" + min_storage_size: Optional[int] = rest_field(name="minStorageSize", visibility=["read"]) + """The minimal supported storage size.""" + max_storage_size: Optional[int] = rest_field(name="maxStorageSize", visibility=["read"]) + """The maximum supported storage size.""" + min_backup_retention_days: Optional[int] = rest_field(name="minBackupRetentionDays", visibility=["read"]) + """Minimal backup retention days.""" + max_backup_retention_days: Optional[int] = rest_field(name="maxBackupRetentionDays", visibility=["read"]) + """Maximum backup retention days.""" + min_backup_interval_hours: Optional[int] = rest_field(name="minBackupIntervalHours", visibility=["read"]) + """Minimal backup interval hours.""" + max_backup_interval_hours: Optional[int] = rest_field(name="maxBackupIntervalHours", visibility=["read"]) + """Maximum backup interval hours.""" + + +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.mysqlflexibleservers.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.mysqlflexibleservers.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 UserAssignedIdentity(_Model): + """Metadata of user assigned identity. + + :ivar principal_id: Principal Id of user assigned identity. + :vartype principal_id: str + :ivar client_id: Client Id of user assigned identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """Principal Id of user assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """Client Id of user assigned identity.""" + + +class ValidateBackupResponse(_Model): + """Represents ValidateBackup API Response. + + :ivar properties: The response properties of a pre backup operation. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponseProperties + """ + + properties: Optional["_models.ValidateBackupResponseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The response properties of a pre backup operation.""" + + __flattened_items = ["number_of_containers"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ValidateBackupResponseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[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 ValidateBackupResponseProperties(_Model): + """ValidateBackup Response Properties. + + :ivar number_of_containers: Estimated no of storage containers required for resource data to be + backed up. + :vartype number_of_containers: int + """ + + number_of_containers: Optional[int] = rest_field( + name="numberOfContainers", visibility=["read", "create", "update", "delete", "query"] + ) + """Estimated no of storage containers required for resource data to be backed up.""" + + @overload + def __init__( + self, + *, + number_of_containers: 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 VirtualNetworkSubnetUsageParameter(_Model): + """Virtual network subnet usage parameter. + + :ivar virtual_network_resource_id: Virtual network resource id. + :vartype virtual_network_resource_id: str + """ + + virtual_network_resource_id: Optional[str] = rest_field( + name="virtualNetworkResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Virtual network resource id.""" + + @overload + def __init__( + self, + *, + virtual_network_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 VirtualNetworkSubnetUsageResult(_Model): + """Virtual network subnet usage data. + + :ivar location: The location name. + :vartype location: str + :ivar subscription_id: The subscription id. + :vartype subscription_id: str + :ivar delegated_subnets_usage: A list of delegated subnet usage. + :vartype delegated_subnets_usage: + list[~azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage] + """ + + location: Optional[str] = rest_field(visibility=["read"]) + """The location name.""" + subscription_id: Optional[str] = rest_field(name="subscriptionId", visibility=["read"]) + """The subscription id.""" + delegated_subnets_usage: Optional[list["_models.DelegatedSubnetUsage"]] = rest_field( + name="delegatedSubnetsUsage", visibility=["read"] + ) + """A list of delegated subnet usage.""" diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py deleted file mode 100644 index ee43b16f0ce4..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py +++ /dev/null @@ -1,4048 +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 azure ad administrators. - - :ivar value: The list of azure ad administrator of a server. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :ivar next_link: The link used to get the next page of operations. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AzureADAdministrator]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.AzureADAdministrator"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of azure ad administrator of a server. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :keyword next_link: The link used to get the next page of operations. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - """ - - _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"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - """ - - -class AdvancedThreatProtection(ProxyResource): - """A server's Advanced Threat Protection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - :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: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState - :ivar provisioning_state: Provisioning state of the Threat Protection. Known values are: - "Succeeded", "Updating", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - "provisioning_state": {"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"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - 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: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState - """ - super().__init__(**kwargs) - self.creation_time: Optional[datetime.datetime] = None - self.state = state - self.provisioning_state: Optional[Union[str, "_models.AdvancedThreatProtectionProvisioningState"]] = None - - -class AdvancedThreatProtectionForUpdate(_serialization.Model): - """Parameters allowed to update advanced threat protection for a server. - - :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: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState - """ - - _attribute_map = { - "state": {"key": "properties.state", "type": "str"}, - } - - 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: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState - """ - super().__init__(**kwargs) - self.state = state - - -class AdvancedThreatProtectionListResult(_serialization.Model): - """The response of a AdvancedThreatProtection list operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The AdvancedThreatProtection items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AdvancedThreatProtection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.AdvancedThreatProtection"]] = None - self.next_link = next_link - - -class AzureADAdministrator(ProxyResource): - """Represents a Administrator. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" - :vartype administrator_type: str or ~azure.mgmt.mysqlflexibleservers.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 identity_resource_id: The resource id of the identity used for AAD Authentication. - :vartype identity_resource_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"}, - "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"}, - "identity_resource_id": {"key": "properties.identityResourceId", "type": "str"}, - } - - def __init__( - self, - *, - administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, - login: Optional[str] = None, - sid: Optional[str] = None, - tenant_id: Optional[str] = None, - identity_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword administrator_type: Type of the sever administrator. "ActiveDirectory" - :paramtype administrator_type: str or ~azure.mgmt.mysqlflexibleservers.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 - :keyword identity_resource_id: The resource id of the identity used for AAD Authentication. - :paramtype identity_resource_id: str - """ - super().__init__(**kwargs) - self.administrator_type = administrator_type - self.login = login - self.sid = sid - self.tenant_id = tenant_id - self.identity_resource_id = identity_resource_id - - -class Backup(_serialization.Model): - """Storage Profile properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar backup_retention_days: Backup retention days for the server. - :vartype backup_retention_days: int - :ivar backup_interval_hours: Backup interval hours for the server. - :vartype backup_interval_hours: int - :ivar geo_redundant_backup: Whether or not geo redundant backup is enabled. Known values are: - "Enabled" and "Disabled". - :vartype geo_redundant_backup: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar earliest_restore_date: Earliest restore point creation time (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - """ - - _validation = { - "earliest_restore_date": {"readonly": True}, - } - - _attribute_map = { - "backup_retention_days": {"key": "backupRetentionDays", "type": "int"}, - "backup_interval_hours": {"key": "backupIntervalHours", "type": "int"}, - "geo_redundant_backup": {"key": "geoRedundantBackup", "type": "str"}, - "earliest_restore_date": {"key": "earliestRestoreDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - backup_retention_days: Optional[int] = None, - backup_interval_hours: Optional[int] = None, - geo_redundant_backup: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword backup_retention_days: Backup retention days for the server. - :paramtype backup_retention_days: int - :keyword backup_interval_hours: Backup interval hours for the server. - :paramtype backup_interval_hours: int - :keyword geo_redundant_backup: Whether or not geo redundant backup is enabled. Known values - are: "Enabled" and "Disabled". - :paramtype geo_redundant_backup: str or - ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - """ - super().__init__(**kwargs) - self.backup_retention_days = backup_retention_days - self.backup_interval_hours = backup_interval_hours - self.geo_redundant_backup = geo_redundant_backup - self.earliest_restore_date: Optional[datetime.datetime] = None - - -class BackupRequestBase(_serialization.Model): - """BackupRequestBase is the base for all backup request. - - All required parameters must be populated in order to send to server. - - :ivar backup_settings: Backup Settings. Required. - :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings - """ - - _validation = { - "backup_settings": {"required": True}, - } - - _attribute_map = { - "backup_settings": {"key": "backupSettings", "type": "BackupSettings"}, - } - - def __init__(self, *, backup_settings: "_models.BackupSettings", **kwargs: Any) -> None: - """ - :keyword backup_settings: Backup Settings. Required. - :paramtype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings - """ - super().__init__(**kwargs) - self.backup_settings = backup_settings - - -class BackupAndExportRequest(BackupRequestBase): - """BackupAndExport API Request. - - All required parameters must be populated in order to send to server. - - :ivar backup_settings: Backup Settings. Required. - :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings - :ivar target_details: Backup Target Store Details. Required. - :vartype target_details: ~azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails - """ - - _validation = { - "backup_settings": {"required": True}, - "target_details": {"required": True}, - } - - _attribute_map = { - "backup_settings": {"key": "backupSettings", "type": "BackupSettings"}, - "target_details": {"key": "targetDetails", "type": "BackupStoreDetails"}, - } - - def __init__( - self, *, backup_settings: "_models.BackupSettings", target_details: "_models.BackupStoreDetails", **kwargs: Any - ) -> None: - """ - :keyword backup_settings: Backup Settings. Required. - :paramtype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings - :keyword target_details: Backup Target Store Details. Required. - :paramtype target_details: ~azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails - """ - super().__init__(backup_settings=backup_settings, **kwargs) - self.target_details = target_details - - -class BackupAndExportResponse(ProxyResource): - """Represents BackupAndExportAPI Response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar error: The error object. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :ivar status: The operation status. Known values are: "Pending", "InProgress", "Succeeded", - "Failed", "CancelInProgress", and "Canceled". - :vartype status: str or ~azure.mgmt.mysqlflexibleservers.models.OperationStatus - :ivar start_time: Start time. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: Operation progress (0-100). - :vartype percent_complete: float - :ivar datasource_size_in_bytes: Size of datasource in bytes. - :vartype datasource_size_in_bytes: int - :ivar data_transferred_in_bytes: Data transferred in bytes. - :vartype data_transferred_in_bytes: int - :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in - key-value pairs. - :vartype backup_metadata: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "error": {"key": "error", "type": "ErrorDetail"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "percent_complete": {"key": "percentComplete", "type": "float"}, - "datasource_size_in_bytes": {"key": "properties.datasourceSizeInBytes", "type": "int"}, - "data_transferred_in_bytes": {"key": "properties.dataTransferredInBytes", "type": "int"}, - "backup_metadata": {"key": "properties.backupMetadata", "type": "str"}, - } - - def __init__( - self, - *, - error: Optional["_models.ErrorDetail"] = None, - status: Optional[Union[str, "_models.OperationStatus"]] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - percent_complete: Optional[float] = None, - datasource_size_in_bytes: Optional[int] = None, - data_transferred_in_bytes: Optional[int] = None, - backup_metadata: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :keyword status: The operation status. Known values are: "Pending", "InProgress", "Succeeded", - "Failed", "CancelInProgress", and "Canceled". - :paramtype status: str or ~azure.mgmt.mysqlflexibleservers.models.OperationStatus - :keyword start_time: Start time. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time. - :paramtype end_time: ~datetime.datetime - :keyword percent_complete: Operation progress (0-100). - :paramtype percent_complete: float - :keyword datasource_size_in_bytes: Size of datasource in bytes. - :paramtype datasource_size_in_bytes: int - :keyword data_transferred_in_bytes: Data transferred in bytes. - :paramtype data_transferred_in_bytes: int - :keyword backup_metadata: Metadata related to backup to be stored for restoring resource in - key-value pairs. - :paramtype backup_metadata: str - """ - super().__init__(**kwargs) - self.error = error - self.status = status - self.start_time = start_time - self.end_time = end_time - self.percent_complete = percent_complete - self.datasource_size_in_bytes = datasource_size_in_bytes - self.data_transferred_in_bytes = data_transferred_in_bytes - self.backup_metadata = backup_metadata - - -class OperationProgressResponseType(_serialization.Model): - """Represents the response properties specific to the operation. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - BackupAndExportResponseType, ImportFromStorageResponseType - - All required parameters must be populated in order to send to server. - - :ivar object_type: Identifies the type of source operation. Required. Known values are: - "BackupAndExportResponse" and "ImportFromStorageResponse". - :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType - """ - - _validation = { - "object_type": {"required": True}, - } - - _attribute_map = { - "object_type": {"key": "objectType", "type": "str"}, - } - - _subtype_map = { - "object_type": { - "BackupAndExportResponse": "BackupAndExportResponseType", - "ImportFromStorageResponse": "ImportFromStorageResponseType", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.object_type: Optional[str] = None - - -class BackupAndExportResponseType(OperationProgressResponseType): - """BackupAndExport Response Properties. - - All required parameters must be populated in order to send to server. - - :ivar object_type: Identifies the type of source operation. Required. Known values are: - "BackupAndExportResponse" and "ImportFromStorageResponse". - :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType - :ivar datasource_size_in_bytes: Size of datasource in bytes. - :vartype datasource_size_in_bytes: int - :ivar data_transferred_in_bytes: Data transferred in bytes. - :vartype data_transferred_in_bytes: int - :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in - key-value pairs. - :vartype backup_metadata: str - """ - - _validation = { - "object_type": {"required": True}, - } - - _attribute_map = { - "object_type": {"key": "objectType", "type": "str"}, - "datasource_size_in_bytes": {"key": "datasourceSizeInBytes", "type": "int"}, - "data_transferred_in_bytes": {"key": "dataTransferredInBytes", "type": "int"}, - "backup_metadata": {"key": "backupMetadata", "type": "str"}, - } - - def __init__( - self, - *, - datasource_size_in_bytes: Optional[int] = None, - data_transferred_in_bytes: Optional[int] = None, - backup_metadata: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword datasource_size_in_bytes: Size of datasource in bytes. - :paramtype datasource_size_in_bytes: int - :keyword data_transferred_in_bytes: Data transferred in bytes. - :paramtype data_transferred_in_bytes: int - :keyword backup_metadata: Metadata related to backup to be stored for restoring resource in - key-value pairs. - :paramtype backup_metadata: str - """ - super().__init__(**kwargs) - self.object_type: str = "BackupAndExportResponse" - self.datasource_size_in_bytes = datasource_size_in_bytes - self.data_transferred_in_bytes = data_transferred_in_bytes - self.backup_metadata = backup_metadata - - -class BackupSettings(_serialization.Model): - """Backup Settings. - - All required parameters must be populated in order to send to server. - - :ivar backup_name: The name of the backup. Required. - :vartype backup_name: str - :ivar backup_format: Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT - USE). Known values are: "CollatedFormat" and "Raw". - :vartype backup_format: str or ~azure.mgmt.mysqlflexibleservers.models.BackupFormat - """ - - _validation = { - "backup_name": {"required": True, "pattern": r"(^[a-z0-9]$)|(^[a-z0-9][a-z0-9-]*[a-z0-9]$)"}, - } - - _attribute_map = { - "backup_name": {"key": "backupName", "type": "str"}, - "backup_format": {"key": "backupFormat", "type": "str"}, - } - - def __init__( - self, *, backup_name: str, backup_format: Optional[Union[str, "_models.BackupFormat"]] = None, **kwargs: Any - ) -> None: - """ - :keyword backup_name: The name of the backup. Required. - :paramtype backup_name: str - :keyword backup_format: Backup Format for the current backup. (CollatedFormat is INTERNAL – DO - NOT USE). Known values are: "CollatedFormat" and "Raw". - :paramtype backup_format: str or ~azure.mgmt.mysqlflexibleservers.models.BackupFormat - """ - super().__init__(**kwargs) - self.backup_name = backup_name - self.backup_format = backup_format - - -class BackupStoreDetails(_serialization.Model): - """Details about the target where the backup content will be stored. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - FullBackupStoreDetails - - All required parameters must be populated in order to send to server. - - :ivar object_type: Type of the specific object - used for deserializing. Required. - :vartype object_type: str - """ - - _validation = { - "object_type": {"required": True}, - } - - _attribute_map = { - "object_type": {"key": "objectType", "type": "str"}, - } - - _subtype_map = {"object_type": {"FullBackupStoreDetails": "FullBackupStoreDetails"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.object_type: Optional[str] = None - - -class CapabilitiesListResult(_serialization.Model): - """location capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The CapabilityProperties items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CapabilityProperties]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.CapabilityProperties"]] = None - self.next_link = next_link - - -class Capability(ProxyResource): - """Represents a location capability set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar supported_geo_backup_regions: supported geo backup regions. - :vartype supported_geo_backup_regions: list[str] - :ivar supported_flexible_server_editions: A list of supported flexible server editions. - :vartype supported_flexible_server_editions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2] - :ivar supported_server_versions: A list of supported server versions. - :vartype supported_server_versions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2] - :ivar supported_features: A list of supported features. - :vartype supported_features: list[~azure.mgmt.mysqlflexibleservers.models.FeatureProperty] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "supported_geo_backup_regions": {"readonly": True}, - "supported_flexible_server_editions": {"readonly": True}, - "supported_server_versions": {"readonly": True}, - "supported_features": {"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"}, - "supported_geo_backup_regions": {"key": "properties.supportedGeoBackupRegions", "type": "[str]"}, - "supported_flexible_server_editions": { - "key": "properties.supportedFlexibleServerEditions", - "type": "[ServerEditionCapabilityV2]", - }, - "supported_server_versions": { - "key": "properties.supportedServerVersions", - "type": "[ServerVersionCapabilityV2]", - }, - "supported_features": {"key": "properties.supportedFeatures", "type": "[FeatureProperty]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.supported_geo_backup_regions: Optional[list[str]] = None - self.supported_flexible_server_editions: Optional[list["_models.ServerEditionCapabilityV2"]] = None - self.supported_server_versions: Optional[list["_models.ServerVersionCapabilityV2"]] = None - self.supported_features: Optional[list["_models.FeatureProperty"]] = None - - -class CapabilityProperties(_serialization.Model): - """Location capabilities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar zone: zone name. - :vartype zone: str - :ivar supported_ha_mode: Supported high availability mode. - :vartype supported_ha_mode: list[str] - :ivar supported_geo_backup_regions: supported geo backup regions. - :vartype supported_geo_backup_regions: list[str] - :ivar supported_flexible_server_editions: A list of supported flexible server editions. - :vartype supported_flexible_server_editions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability] - """ - - _validation = { - "zone": {"readonly": True}, - "supported_ha_mode": {"readonly": True}, - "supported_geo_backup_regions": {"readonly": True}, - "supported_flexible_server_editions": {"readonly": True}, - } - - _attribute_map = { - "zone": {"key": "zone", "type": "str"}, - "supported_ha_mode": {"key": "supportedHAMode", "type": "[str]"}, - "supported_geo_backup_regions": {"key": "supportedGeoBackupRegions", "type": "[str]"}, - "supported_flexible_server_editions": { - "key": "supportedFlexibleServerEditions", - "type": "[ServerEditionCapability]", - }, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.zone: Optional[str] = None - self.supported_ha_mode: Optional[list[str]] = None - self.supported_geo_backup_regions: Optional[list[str]] = None - self.supported_flexible_server_editions: Optional[list["_models.ServerEditionCapability"]] = None - - -class CapabilitySetsList(_serialization.Model): - """location capability set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The CapabilitySetsList items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Capability] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Capability]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Capability"]] = None - self.next_link = next_link - - -class Configuration(ProxyResource): - """Represents a Configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar value: Value of the configuration. - :vartype value: str - :ivar current_value: Current value of the configuration. - :vartype current_value: str - :ivar description: Description of the configuration. - :vartype description: str - :ivar documentation_link: The link used to get the document from community or Azure site. - :vartype documentation_link: str - :ivar default_value: Default value of the configuration. - :vartype default_value: str - :ivar data_type: Data type of the configuration. - :vartype data_type: str - :ivar allowed_values: Allowed values of the configuration. - :vartype allowed_values: str - :ivar source: Source of the configuration. Known values are: "system-default" and - "user-override". - :vartype source: str or ~azure.mgmt.mysqlflexibleservers.models.ConfigurationSource - :ivar is_read_only: If is the configuration read only. Known values are: "True" and "False". - :vartype is_read_only: str or ~azure.mgmt.mysqlflexibleservers.models.IsReadOnly - :ivar is_config_pending_restart: If is the configuration pending restart or not. Known values - are: "True" and "False". - :vartype is_config_pending_restart: str or - ~azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart - :ivar is_dynamic_config: If is the configuration dynamic. Known values are: "True" and "False". - :vartype is_dynamic_config: str or ~azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "description": {"readonly": True}, - "documentation_link": {"readonly": True}, - "default_value": {"readonly": True}, - "data_type": {"readonly": True}, - "allowed_values": {"readonly": True}, - "is_read_only": {"readonly": True}, - "is_config_pending_restart": {"readonly": True}, - "is_dynamic_config": {"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"}, - "value": {"key": "properties.value", "type": "str"}, - "current_value": {"key": "properties.currentValue", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "documentation_link": {"key": "properties.documentationLink", "type": "str"}, - "default_value": {"key": "properties.defaultValue", "type": "str"}, - "data_type": {"key": "properties.dataType", "type": "str"}, - "allowed_values": {"key": "properties.allowedValues", "type": "str"}, - "source": {"key": "properties.source", "type": "str"}, - "is_read_only": {"key": "properties.isReadOnly", "type": "str"}, - "is_config_pending_restart": {"key": "properties.isConfigPendingRestart", "type": "str"}, - "is_dynamic_config": {"key": "properties.isDynamicConfig", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[str] = None, - current_value: Optional[str] = None, - source: Optional[Union[str, "_models.ConfigurationSource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Value of the configuration. - :paramtype value: str - :keyword current_value: Current value of the configuration. - :paramtype current_value: str - :keyword source: Source of the configuration. Known values are: "system-default" and - "user-override". - :paramtype source: str or ~azure.mgmt.mysqlflexibleservers.models.ConfigurationSource - """ - super().__init__(**kwargs) - self.value = value - self.current_value = current_value - self.description: Optional[str] = None - self.documentation_link: Optional[str] = None - self.default_value: Optional[str] = None - self.data_type: Optional[str] = None - self.allowed_values: Optional[str] = None - self.source = source - self.is_read_only: Optional[Union[str, "_models.IsReadOnly"]] = None - self.is_config_pending_restart: Optional[Union[str, "_models.IsConfigPendingRestart"]] = None - self.is_dynamic_config: Optional[Union[str, "_models.IsDynamicConfig"]] = None - - -class ConfigurationForBatchUpdate(_serialization.Model): - """Represents a Configuration. - - :ivar name: Name of the configuration. - :vartype name: str - :ivar value: Value of the configuration. - :vartype value: str - :ivar source: Source of the configuration. - :vartype source: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "properties.value", "type": "str"}, - "source": {"key": "properties.source", "type": "str"}, - } - - def __init__( - self, *, name: Optional[str] = None, value: Optional[str] = None, source: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Name of the configuration. - :paramtype name: str - :keyword value: Value of the configuration. - :paramtype value: str - :keyword source: Source of the configuration. - :paramtype source: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - self.source = source - - -class ConfigurationListForBatchUpdate(_serialization.Model): - """A list of server configurations to update. - - :ivar value: The list of server configurations. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate] - :ivar reset_all_to_default: Whether to reset all server parameters to default. Known values - are: "True" and "False". - :vartype reset_all_to_default: str or ~azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ConfigurationForBatchUpdate]"}, - "reset_all_to_default": {"key": "resetAllToDefault", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[list["_models.ConfigurationForBatchUpdate"]] = None, - reset_all_to_default: Optional[Union[str, "_models.ResetAllToDefault"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of server configurations. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate] - :keyword reset_all_to_default: Whether to reset all server parameters to default. Known values - are: "True" and "False". - :paramtype reset_all_to_default: str or - ~azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault - """ - super().__init__(**kwargs) - self.value = value - self.reset_all_to_default = reset_all_to_default - - -class ConfigurationListResult(_serialization.Model): - """The response of a Configuration list operation. - - :ivar value: The Configuration items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Configuration]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Configuration"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The Configuration items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Database(ProxyResource): - """Represents a Database. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar charset: The charset of the database. - :vartype charset: str - :ivar collation: The collation of the database. - :vartype collation: 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"}, - "charset": {"key": "properties.charset", "type": "str"}, - "collation": {"key": "properties.collation", "type": "str"}, - } - - def __init__(self, *, charset: Optional[str] = None, collation: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword charset: The charset of the database. - :paramtype charset: str - :keyword collation: The collation of the database. - :paramtype collation: str - """ - super().__init__(**kwargs) - self.charset = charset - self.collation = collation - - -class DatabaseListResult(_serialization.Model): - """The response of a Database list operation. - - :ivar value: The Database items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Database] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Database]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Database"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The Database items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Database] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataEncryption(_serialization.Model): - """The date encryption for cmk. - - :ivar primary_user_assigned_identity_id: Primary user identity resource id. - :vartype primary_user_assigned_identity_id: str - :ivar primary_key_uri: Primary key uri. - :vartype primary_key_uri: str - :ivar geo_backup_user_assigned_identity_id: Geo backup user identity resource id as identity - can't cross region, need identity in same region as geo backup. - :vartype geo_backup_user_assigned_identity_id: str - :ivar geo_backup_key_uri: Geo backup key uri as key vault can't cross region, need cmk in same - region as geo backup. - :vartype geo_backup_key_uri: str - :ivar type: The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known - values are: "AzureKeyVault" and "SystemManaged". - :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.DataEncryptionType - """ - - _attribute_map = { - "primary_user_assigned_identity_id": {"key": "primaryUserAssignedIdentityId", "type": "str"}, - "primary_key_uri": {"key": "primaryKeyURI", "type": "str"}, - "geo_backup_user_assigned_identity_id": {"key": "geoBackupUserAssignedIdentityId", "type": "str"}, - "geo_backup_key_uri": {"key": "geoBackupKeyURI", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - primary_user_assigned_identity_id: Optional[str] = None, - primary_key_uri: Optional[str] = None, - geo_backup_user_assigned_identity_id: Optional[str] = None, - geo_backup_key_uri: Optional[str] = None, - type: Optional[Union[str, "_models.DataEncryptionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword primary_user_assigned_identity_id: Primary user identity resource id. - :paramtype primary_user_assigned_identity_id: str - :keyword primary_key_uri: Primary key uri. - :paramtype primary_key_uri: str - :keyword geo_backup_user_assigned_identity_id: Geo backup user identity resource id as identity - can't cross region, need identity in same region as geo backup. - :paramtype geo_backup_user_assigned_identity_id: str - :keyword geo_backup_key_uri: Geo backup key uri as key vault can't cross region, need cmk in - same region as geo backup. - :paramtype geo_backup_key_uri: str - :keyword type: The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known - values are: "AzureKeyVault" and "SystemManaged". - :paramtype type: str or ~azure.mgmt.mysqlflexibleservers.models.DataEncryptionType - """ - super().__init__(**kwargs) - self.primary_user_assigned_identity_id = primary_user_assigned_identity_id - self.primary_key_uri = primary_key_uri - self.geo_backup_user_assigned_identity_id = geo_backup_user_assigned_identity_id - self.geo_backup_key_uri = geo_backup_key_uri - self.type = type - - -class DelegatedSubnetUsage(_serialization.Model): - """Delegated subnet usage data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar subnet_name: name of the subnet. - :vartype subnet_name: str - :ivar usage: Number of used delegated subnets. - :vartype usage: int - """ - - _validation = { - "subnet_name": {"readonly": True}, - "usage": {"readonly": True}, - } - - _attribute_map = { - "subnet_name": {"key": "subnetName", "type": "str"}, - "usage": {"key": "usage", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.subnet_name: Optional[str] = None - self.usage: 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.mysqlflexibleservers.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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.mysqlflexibleservers.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class FeatureProperty(_serialization.Model): - """Server version capabilities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar feature_name: feature name. - :vartype feature_name: str - :ivar feature_value: feature value. - :vartype feature_value: str - """ - - _validation = { - "feature_name": {"readonly": True}, - "feature_value": {"readonly": True}, - } - - _attribute_map = { - "feature_name": {"key": "featureName", "type": "str"}, - "feature_value": {"key": "featureValue", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.feature_name: Optional[str] = None - self.feature_value: Optional[str] = None - - -class FirewallRule(ProxyResource): - """Represents a server firewall rule. - - 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: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar start_ip_address: The start IP address of the server firewall rule. Must be IPv4 format. - Required. - :vartype start_ip_address: str - :ivar end_ip_address: The end IP address of the server firewall rule. Must be IPv4 format. - Required. - :vartype end_ip_address: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "start_ip_address": { - "required": True, - "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", - }, - "end_ip_address": { - "required": True, - "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", - }, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "start_ip_address": {"key": "properties.startIpAddress", "type": "str"}, - "end_ip_address": {"key": "properties.endIpAddress", "type": "str"}, - } - - def __init__(self, *, start_ip_address: str, end_ip_address: str, **kwargs: Any) -> None: - """ - :keyword start_ip_address: The start IP address of the server firewall rule. Must be IPv4 - format. Required. - :paramtype start_ip_address: str - :keyword end_ip_address: The end IP address of the server firewall rule. Must be IPv4 format. - Required. - :paramtype end_ip_address: str - """ - super().__init__(**kwargs) - self.start_ip_address = start_ip_address - self.end_ip_address = end_ip_address - - -class FirewallRuleListResult(_serialization.Model): - """The response of a FirewallRule list operation. - - :ivar value: The FirewallRule items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[FirewallRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.FirewallRule"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The FirewallRule items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class FullBackupStoreDetails(BackupStoreDetails): - """FullBackupStoreDetails is used for scenarios where backup data is streamed/copied over to a - storage destination. - - All required parameters must be populated in order to send to server. - - :ivar object_type: Type of the specific object - used for deserializing. Required. - :vartype object_type: str - :ivar sas_uri_list: SASUriList of storage containers where backup data is to be - streamed/copied. Required. - :vartype sas_uri_list: list[str] - """ - - _validation = { - "object_type": {"required": True}, - "sas_uri_list": {"required": True}, - } - - _attribute_map = { - "object_type": {"key": "objectType", "type": "str"}, - "sas_uri_list": {"key": "sasUriList", "type": "[str]"}, - } - - def __init__(self, *, sas_uri_list: list[str], **kwargs: Any) -> None: - """ - :keyword sas_uri_list: SASUriList of storage containers where backup data is to be - streamed/copied. Required. - :paramtype sas_uri_list: list[str] - """ - super().__init__(**kwargs) - self.object_type: str = "FullBackupStoreDetails" - self.sas_uri_list = sas_uri_list - - -class GetPrivateDnsZoneSuffixResponse(_serialization.Model): - """The response of get private dns zone suffix. - - :ivar private_dns_zone_suffix: Represents the private DNS zone suffix. - :vartype private_dns_zone_suffix: str - """ - - _attribute_map = { - "private_dns_zone_suffix": {"key": "privateDnsZoneSuffix", "type": "str"}, - } - - def __init__(self, *, private_dns_zone_suffix: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword private_dns_zone_suffix: Represents the private DNS zone suffix. - :paramtype private_dns_zone_suffix: str - """ - super().__init__(**kwargs) - self.private_dns_zone_suffix = private_dns_zone_suffix - - -class HighAvailability(_serialization.Model): - """High availability properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar mode: High availability mode for a server. Known values are: "Disabled", "ZoneRedundant", - and "SameZone". - :vartype mode: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode - :ivar state: The state of server high availability. Known values are: "NotEnabled", - "CreatingStandby", "Healthy", "FailingOver", and "RemovingStandby". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState - :ivar standby_availability_zone: Availability zone of the standby server. - :vartype standby_availability_zone: str - """ - - _validation = { - "state": {"readonly": True}, - } - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "standby_availability_zone": {"key": "standbyAvailabilityZone", "type": "str"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = None, - standby_availability_zone: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: High availability mode for a server. Known values are: "Disabled", - "ZoneRedundant", and "SameZone". - :paramtype mode: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode - :keyword standby_availability_zone: Availability zone of the standby server. - :paramtype standby_availability_zone: str - """ - super().__init__(**kwargs) - self.mode = mode - self.state: Optional[Union[str, "_models.HighAvailabilityState"]] = None - self.standby_availability_zone = standby_availability_zone - - -class HighAvailabilityValidationEstimation(_serialization.Model): - """High availability validation properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar estimated_downtime: Estimated seconds of downtime for the deployment. - :vartype estimated_downtime: int - :ivar scheduled_standby_availability_zone: Scheduled Availability zone of the standby server. - :vartype scheduled_standby_availability_zone: str - :ivar expected_standby_availability_zone: Expected Availability zone of the standby server. - :vartype expected_standby_availability_zone: str - """ - - _validation = { - "estimated_downtime": {"readonly": True}, - "scheduled_standby_availability_zone": {"readonly": True}, - } - - _attribute_map = { - "estimated_downtime": {"key": "estimatedDowntime", "type": "int"}, - "scheduled_standby_availability_zone": {"key": "scheduledStandbyAvailabilityZone", "type": "str"}, - "expected_standby_availability_zone": {"key": "expectedStandbyAvailabilityZone", "type": "str"}, - } - - def __init__(self, *, expected_standby_availability_zone: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword expected_standby_availability_zone: Expected Availability zone of the standby server. - :paramtype expected_standby_availability_zone: str - """ - super().__init__(**kwargs) - self.estimated_downtime: Optional[int] = None - self.scheduled_standby_availability_zone: Optional[str] = None - self.expected_standby_availability_zone = expected_standby_availability_zone - - -class ImportFromStorageResponseType(OperationProgressResponseType): - """ImportFromStorage Response Properties. - - All required parameters must be populated in order to send to server. - - :ivar object_type: Identifies the type of source operation. Required. Known values are: - "BackupAndExportResponse" and "ImportFromStorageResponse". - :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType - :ivar estimated_completion_time: The estimated time of operation completion. - :vartype estimated_completion_time: ~datetime.datetime - """ - - _validation = { - "object_type": {"required": True}, - } - - _attribute_map = { - "object_type": {"key": "objectType", "type": "str"}, - "estimated_completion_time": {"key": "estimatedCompletionTime", "type": "iso-8601"}, - } - - def __init__(self, *, estimated_completion_time: Optional[datetime.datetime] = None, **kwargs: Any) -> None: - """ - :keyword estimated_completion_time: The estimated time of operation completion. - :paramtype estimated_completion_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.object_type: str = "ImportFromStorageResponse" - self.estimated_completion_time = estimated_completion_time - - -class ImportSourceProperties(_serialization.Model): - """Import source related properties. - - :ivar storage_type: Storage type of import source. "AzureBlob" - :vartype storage_type: str or ~azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType - :ivar storage_url: Uri of the import source storage. - :vartype storage_url: str - :ivar sas_token: Sas token for accessing source storage. Read and list permissions are required - for sas token. - :vartype sas_token: str - :ivar data_dir_path: Relative path of data directory in storage. - :vartype data_dir_path: str - """ - - _attribute_map = { - "storage_type": {"key": "storageType", "type": "str"}, - "storage_url": {"key": "storageUrl", "type": "str"}, - "sas_token": {"key": "sasToken", "type": "str"}, - "data_dir_path": {"key": "dataDirPath", "type": "str"}, - } - - def __init__( - self, - *, - storage_type: Optional[Union[str, "_models.ImportSourceStorageType"]] = None, - storage_url: Optional[str] = None, - sas_token: Optional[str] = None, - data_dir_path: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_type: Storage type of import source. "AzureBlob" - :paramtype storage_type: str or ~azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType - :keyword storage_url: Uri of the import source storage. - :paramtype storage_url: str - :keyword sas_token: Sas token for accessing source storage. Read and list permissions are - required for sas token. - :paramtype sas_token: str - :keyword data_dir_path: Relative path of data directory in storage. - :paramtype data_dir_path: str - """ - super().__init__(**kwargs) - self.storage_type = storage_type - self.storage_url = storage_url - self.sas_token = sas_token - self.data_dir_path = data_dir_path - - -class LogFile(ProxyResource): - """Represents a logFile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar size_in_kb: The size in kb of the logFile. - :vartype size_in_kb: int - :ivar created_time: Creation timestamp of the log file. - :vartype created_time: ~datetime.datetime - :ivar type_properties_type: Type of the log file. - :vartype type_properties_type: str - :ivar last_modified_time: Last modified timestamp of the log file. - :vartype last_modified_time: ~datetime.datetime - :ivar url: The url to download the log file from. - :vartype url: 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"}, - "size_in_kb": {"key": "properties.sizeInKB", "type": "int"}, - "created_time": {"key": "properties.createdTime", "type": "iso-8601"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, - "url": {"key": "properties.url", "type": "str"}, - } - - def __init__( - self, - *, - size_in_kb: Optional[int] = None, - created_time: Optional[datetime.datetime] = None, - type_properties_type: Optional[str] = None, - last_modified_time: Optional[datetime.datetime] = None, - url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword size_in_kb: The size in kb of the logFile. - :paramtype size_in_kb: int - :keyword created_time: Creation timestamp of the log file. - :paramtype created_time: ~datetime.datetime - :keyword type_properties_type: Type of the log file. - :paramtype type_properties_type: str - :keyword last_modified_time: Last modified timestamp of the log file. - :paramtype last_modified_time: ~datetime.datetime - :keyword url: The url to download the log file from. - :paramtype url: str - """ - super().__init__(**kwargs) - self.size_in_kb = size_in_kb - self.created_time = created_time - self.type_properties_type = type_properties_type - self.last_modified_time = last_modified_time - self.url = url - - -class LogFileListResult(_serialization.Model): - """The response of a LogFile list operation. - - :ivar value: The LogFile items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.LogFile] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[LogFile]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.LogFile"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The LogFile items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.LogFile] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Maintenance(ProxyResource): - """Represents a maintenance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar maintenance_type: A string defines maintenance type. Known values are: - "RoutineMaintenance", "MinorVersionUpgrade", "SecurityPatches", and "HotFixes". - :vartype maintenance_type: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceType - :ivar maintenance_state: A string describes the maintenance status. Known values are: - "Scheduled", "ReScheduled", "InPreparation", "Processing", "Completed", and "Canceled". - :vartype maintenance_state: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceState - :ivar maintenance_start_time: The start time for a maintenance. - :vartype maintenance_start_time: ~datetime.datetime - :ivar maintenance_end_time: The end time for a maintenance. - :vartype maintenance_end_time: ~datetime.datetime - :ivar maintenance_execution_start_time: The start time for a maintenance execution. - :vartype maintenance_execution_start_time: ~datetime.datetime - :ivar maintenance_execution_end_time: The end time for a maintenance execution. - :vartype maintenance_execution_end_time: ~datetime.datetime - :ivar maintenance_available_schedule_min_time: The min time the maintenance can be rescheduled. - :vartype maintenance_available_schedule_min_time: ~datetime.datetime - :ivar maintenance_available_schedule_max_time: The max time the maintenance can be rescheduled. - :vartype maintenance_available_schedule_max_time: ~datetime.datetime - :ivar maintenance_title: The maintenance title. - :vartype maintenance_title: str - :ivar maintenance_description: The maintenance description. - :vartype maintenance_description: str - :ivar provisioning_state: Provisioning state of the Maintenance. Known values are: "Succeeded", - "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "maintenance_type": {"readonly": True}, - "maintenance_state": {"readonly": True}, - "maintenance_end_time": {"readonly": True}, - "maintenance_execution_start_time": {"readonly": True}, - "maintenance_execution_end_time": {"readonly": True}, - "maintenance_available_schedule_min_time": {"readonly": True}, - "maintenance_available_schedule_max_time": {"readonly": True}, - "maintenance_title": {"readonly": True}, - "maintenance_description": {"readonly": True}, - "provisioning_state": {"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"}, - "maintenance_type": {"key": "properties.maintenanceType", "type": "str"}, - "maintenance_state": {"key": "properties.maintenanceState", "type": "str"}, - "maintenance_start_time": {"key": "properties.maintenanceStartTime", "type": "iso-8601"}, - "maintenance_end_time": {"key": "properties.maintenanceEndTime", "type": "iso-8601"}, - "maintenance_execution_start_time": {"key": "properties.maintenanceExecutionStartTime", "type": "iso-8601"}, - "maintenance_execution_end_time": {"key": "properties.maintenanceExecutionEndTime", "type": "iso-8601"}, - "maintenance_available_schedule_min_time": { - "key": "properties.maintenanceAvailableScheduleMinTime", - "type": "iso-8601", - }, - "maintenance_available_schedule_max_time": { - "key": "properties.maintenanceAvailableScheduleMaxTime", - "type": "iso-8601", - }, - "maintenance_title": {"key": "properties.maintenanceTitle", "type": "str"}, - "maintenance_description": {"key": "properties.maintenanceDescription", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, *, maintenance_start_time: Optional[datetime.datetime] = None, **kwargs: Any) -> None: - """ - :keyword maintenance_start_time: The start time for a maintenance. - :paramtype maintenance_start_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.maintenance_type: Optional[Union[str, "_models.MaintenanceType"]] = None - self.maintenance_state: Optional[Union[str, "_models.MaintenanceState"]] = None - self.maintenance_start_time = maintenance_start_time - self.maintenance_end_time: Optional[datetime.datetime] = None - self.maintenance_execution_start_time: Optional[datetime.datetime] = None - self.maintenance_execution_end_time: Optional[datetime.datetime] = None - self.maintenance_available_schedule_min_time: Optional[datetime.datetime] = None - self.maintenance_available_schedule_max_time: Optional[datetime.datetime] = None - self.maintenance_title: Optional[str] = None - self.maintenance_description: Optional[str] = None - self.provisioning_state: Optional[Union[str, "_models.MaintenanceProvisioningState"]] = None - - -class MaintenanceListResult(_serialization.Model): - """The response of a Maintenance list operation. - - :ivar value: The Maintenance items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Maintenance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Maintenance"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The Maintenance items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class MaintenancePolicy(_serialization.Model): - """Maintenance policy of a server. - - :ivar patch_strategy: The patch strategy of this server. Known values are: "Regular" and - "VirtualCanary". - :vartype patch_strategy: str or ~azure.mgmt.mysqlflexibleservers.models.PatchStrategy - """ - - _attribute_map = { - "patch_strategy": {"key": "patchStrategy", "type": "str"}, - } - - def __init__(self, *, patch_strategy: Optional[Union[str, "_models.PatchStrategy"]] = None, **kwargs: Any) -> None: - """ - :keyword patch_strategy: The patch strategy of this server. Known values are: "Regular" and - "VirtualCanary". - :paramtype patch_strategy: str or ~azure.mgmt.mysqlflexibleservers.models.PatchStrategy - """ - super().__init__(**kwargs) - self.patch_strategy = patch_strategy - - -class MaintenanceUpdate(_serialization.Model): - """Represents a maintenance update parameter. - - :ivar maintenance_start_time: The start time for a maintenance. - :vartype maintenance_start_time: ~datetime.datetime - """ - - _attribute_map = { - "maintenance_start_time": {"key": "properties.maintenanceStartTime", "type": "iso-8601"}, - } - - def __init__(self, *, maintenance_start_time: Optional[datetime.datetime] = None, **kwargs: Any) -> None: - """ - :keyword maintenance_start_time: The start time for a maintenance. - :paramtype maintenance_start_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.maintenance_start_time = maintenance_start_time - - -class MaintenanceWindow(_serialization.Model): - """Maintenance window of a server. - - :ivar custom_window: indicates whether custom window is enabled or disabled. - :vartype custom_window: str - :ivar start_hour: start hour for maintenance window. - :vartype start_hour: int - :ivar start_minute: start minute for maintenance window. - :vartype start_minute: int - :ivar day_of_week: day of week for maintenance window. - :vartype day_of_week: int - :ivar batch_of_maintenance: The batch of maintenance when enabled the custom managed - maintenance window of a server. Known values are: "Default", "Batch1", and "Batch2". - :vartype batch_of_maintenance: str or - ~azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance - """ - - _attribute_map = { - "custom_window": {"key": "customWindow", "type": "str"}, - "start_hour": {"key": "startHour", "type": "int"}, - "start_minute": {"key": "startMinute", "type": "int"}, - "day_of_week": {"key": "dayOfWeek", "type": "int"}, - "batch_of_maintenance": {"key": "batchOfMaintenance", "type": "str"}, - } - - def __init__( - self, - *, - custom_window: Optional[str] = None, - start_hour: Optional[int] = None, - start_minute: Optional[int] = None, - day_of_week: Optional[int] = None, - batch_of_maintenance: Optional[Union[str, "_models.BatchOfMaintenance"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_window: indicates whether custom window is enabled or disabled. - :paramtype custom_window: str - :keyword start_hour: start hour for maintenance window. - :paramtype start_hour: int - :keyword start_minute: start minute for maintenance window. - :paramtype start_minute: int - :keyword day_of_week: day of week for maintenance window. - :paramtype day_of_week: int - :keyword batch_of_maintenance: The batch of maintenance when enabled the custom managed - maintenance window of a server. Known values are: "Default", "Batch1", and "Batch2". - :paramtype batch_of_maintenance: str or - ~azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance - """ - super().__init__(**kwargs) - self.custom_window = custom_window - self.start_hour = start_hour - self.start_minute = start_minute - self.day_of_week = day_of_week - self.batch_of_maintenance = batch_of_maintenance - - -class MySQLServerIdentity(_serialization.Model): - """Properties to configure Identity for Bring your Own Keys. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: ObjectId from the KeyVault. - :vartype principal_id: str - :ivar tenant_id: TenantId from the KeyVault. - :vartype tenant_id: str - :ivar type: Type of managed service identity. "UserAssigned" - :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType - :ivar user_assigned_identities: Metadata of user assigned identity. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, - user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity. "UserAssigned" - :paramtype type: str or ~azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType - :keyword user_assigned_identities: Metadata of user assigned identity. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class MySQLServerSku(_serialization.Model): - """Billing information related properties of a server. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the sku, e.g. Standard_D32s_v3. Required. - :vartype name: str - :ivar tier: The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: - "Burstable", "GeneralPurpose", and "MemoryOptimized". - :vartype tier: str or ~azure.mgmt.mysqlflexibleservers.models.ServerSkuTier - """ - - _validation = { - "name": {"required": True}, - "tier": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: str, tier: Union[str, "_models.ServerSkuTier"], **kwargs: Any) -> None: - """ - :keyword name: The name of the sku, e.g. Standard_D32s_v3. Required. - :paramtype name: str - :keyword tier: The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: - "Burstable", "GeneralPurpose", and "MemoryOptimized". - :paramtype tier: str or ~azure.mgmt.mysqlflexibleservers.models.ServerSkuTier - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - - -class NameAvailability(_serialization.Model): - """Represents a resource name availability. - - :ivar message: Error Message. - :vartype message: str - :ivar name_available: Indicates whether the resource name is available. - :vartype name_available: bool - :ivar reason: Reason for name being unavailable. - :vartype reason: str - """ - - _attribute_map = { - "message": {"key": "message", "type": "str"}, - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__( - self, - *, - message: Optional[str] = None, - name_available: Optional[bool] = None, - reason: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword message: Error Message. - :paramtype message: str - :keyword name_available: Indicates whether the resource name is available. - :paramtype name_available: bool - :keyword reason: Reason for name being unavailable. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.message = message - self.name_available = name_available - self.reason = reason - - -class NameAvailabilityRequest(_serialization.Model): - """Request from client to check resource name availability. - - All required parameters must be populated in order to send to server. - - :ivar name: Resource name to verify. Required. - :vartype name: str - :ivar type: Resource type used for verification. - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, name: str, type: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: Resource name to verify. Required. - :paramtype name: str - :keyword type: Resource type used for verification. - :paramtype type: str - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class Network(_serialization.Model): - """Network related properties of a server. - - :ivar public_network_access: Whether or not public network access is allowed for this server. - Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and - "Disabled". - :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar delegated_subnet_resource_id: Delegated subnet resource id used to setup vnet for a - server. - :vartype delegated_subnet_resource_id: str - :ivar private_dns_zone_resource_id: Private DNS zone resource id. - :vartype private_dns_zone_resource_id: str - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - "delegated_subnet_resource_id": {"key": "delegatedSubnetResourceId", "type": "str"}, - "private_dns_zone_resource_id": {"key": "privateDnsZoneResourceId", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - delegated_subnet_resource_id: Optional[str] = None, - private_dns_zone_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: Whether or not public network access is allowed for this - server. Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and - "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :keyword delegated_subnet_resource_id: Delegated subnet resource id used to setup vnet for a - server. - :paramtype delegated_subnet_resource_id: str - :keyword private_dns_zone_resource_id: Private DNS zone resource id. - :paramtype private_dns_zone_resource_id: str - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - self.delegated_subnet_resource_id = delegated_subnet_resource_id - self.private_dns_zone_resource_id = private_dns_zone_resource_id - - -class Operation(_serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.mysqlflexibleservers.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", - and "user,system". - :vartype origin: str or ~azure.mgmt.mysqlflexibleservers.models.Origin - :ivar properties: Additional descriptions for the operation. - :vartype properties: dict[str, any] - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"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, - *, - display: Optional["_models.OperationDisplay"] = None, - properties: Optional[dict[str, Any]] = None, - **kwargs: Any - ) -> None: - """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.mysqlflexibleservers.models.OperationDisplay - :keyword properties: Additional descriptions for the operation. - :paramtype properties: dict[str, any] - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.display = display - self.origin: Optional[Union[str, "_models.Origin"]] = None - self.properties = properties - - -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, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :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 OperationListResult(_serialization.Model): - """The static parameters for a resource group based resource. - - :ivar value: The Operation items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Operation] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The Operation items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Operation] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OperationStatusResult(_serialization.Model): - """The current status of an async operation. - - 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: Fully qualified ID for the async operation. - :vartype id: str - :ivar resource_id: Fully qualified ID of the resource against which the original async - operation was started. - :vartype resource_id: str - :ivar name: Name of the async operation. - :vartype name: str - :ivar status: Operation status. Required. - :vartype status: str - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar start_time: The start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the operation. - :vartype end_time: ~datetime.datetime - :ivar operations: The operations list. - :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - """ - - _validation = { - "resource_id": {"readonly": True}, - "status": {"required": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "percent_complete": {"key": "percentComplete", "type": "float"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "operations": {"key": "operations", "type": "[OperationStatusResult]"}, - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__( - self, - *, - status: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - percent_complete: Optional[float] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - operations: Optional[list["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetail"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Fully qualified ID for the async operation. - :paramtype id: str - :keyword name: Name of the async operation. - :paramtype name: str - :keyword status: Operation status. Required. - :paramtype status: str - :keyword percent_complete: Percent of the operation that is complete. - :paramtype percent_complete: float - :keyword start_time: The start time of the operation. - :paramtype start_time: ~datetime.datetime - :keyword end_time: The end time of the operation. - :paramtype end_time: ~datetime.datetime - :keyword operations: The operations list. - :paramtype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - """ - super().__init__(**kwargs) - self.id = id - self.resource_id: Optional[str] = None - self.name = name - self.status = status - self.percent_complete = percent_complete - self.start_time = start_time - self.end_time = end_time - self.operations = operations - self.error = error - - -class OperationProgressResult(OperationStatusResult): - """Represents Operation Results API Response. - - 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: Fully qualified ID for the async operation. - :vartype id: str - :ivar resource_id: Fully qualified ID of the resource against which the original async - operation was started. - :vartype resource_id: str - :ivar name: Name of the async operation. - :vartype name: str - :ivar status: Operation status. Required. - :vartype status: str - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar start_time: The start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the operation. - :vartype end_time: ~datetime.datetime - :ivar operations: The operations list. - :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :ivar properties: The response properties specific to the operation. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType - """ - - _validation = { - "resource_id": {"readonly": True}, - "status": {"required": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "percent_complete": {"key": "percentComplete", "type": "float"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "operations": {"key": "operations", "type": "[OperationStatusResult]"}, - "error": {"key": "error", "type": "ErrorDetail"}, - "properties": {"key": "properties", "type": "OperationProgressResponseType"}, - } - - def __init__( - self, - *, - status: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - percent_complete: Optional[float] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - operations: Optional[list["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetail"] = None, - properties: Optional["_models.OperationProgressResponseType"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Fully qualified ID for the async operation. - :paramtype id: str - :keyword name: Name of the async operation. - :paramtype name: str - :keyword status: Operation status. Required. - :paramtype status: str - :keyword percent_complete: Percent of the operation that is complete. - :paramtype percent_complete: float - :keyword start_time: The start time of the operation. - :paramtype start_time: ~datetime.datetime - :keyword end_time: The end time of the operation. - :paramtype end_time: ~datetime.datetime - :keyword operations: The operations list. - :paramtype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :keyword properties: The response properties specific to the operation. - :paramtype properties: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType - """ - super().__init__( - id=id, - name=name, - status=status, - percent_complete=percent_complete, - start_time=start_time, - end_time=end_time, - operations=operations, - error=error, - **kwargs - ) - self.properties = properties - - -class OperationStatusExtendedResult(OperationStatusResult): - """Represents Operation Results API Response. - - 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: Fully qualified ID for the async operation. - :vartype id: str - :ivar resource_id: Fully qualified ID of the resource against which the original async - operation was started. - :vartype resource_id: str - :ivar name: Name of the async operation. - :vartype name: str - :ivar status: Operation status. Required. - :vartype status: str - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar start_time: The start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the operation. - :vartype end_time: ~datetime.datetime - :ivar operations: The operations list. - :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :ivar properties: The extended properties of Operation Results. - :vartype properties: dict[str, any] - """ - - _validation = { - "resource_id": {"readonly": True}, - "status": {"required": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "percent_complete": {"key": "percentComplete", "type": "float"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "operations": {"key": "operations", "type": "[OperationStatusResult]"}, - "error": {"key": "error", "type": "ErrorDetail"}, - "properties": {"key": "properties", "type": "{object}"}, - } - - def __init__( - self, - *, - status: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - percent_complete: Optional[float] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - operations: Optional[list["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetail"] = None, - properties: Optional[dict[str, Any]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Fully qualified ID for the async operation. - :paramtype id: str - :keyword name: Name of the async operation. - :paramtype name: str - :keyword status: Operation status. Required. - :paramtype status: str - :keyword percent_complete: Percent of the operation that is complete. - :paramtype percent_complete: float - :keyword start_time: The start time of the operation. - :paramtype start_time: ~datetime.datetime - :keyword end_time: The end time of the operation. - :paramtype end_time: ~datetime.datetime - :keyword operations: The operations list. - :paramtype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :keyword properties: The extended properties of Operation Results. - :paramtype properties: dict[str, any] - """ - super().__init__( - id=id, - name=name, - status=status, - percent_complete=percent_complete, - start_time=start_time, - end_time=end_time, - operations=operations, - error=error, - **kwargs - ) - self.properties = properties - - -class PrivateEndpoint(_serialization.Model): - """The private endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for private endpoint. - :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 PrivateEndpointConnection(Resource): - """The private endpoint connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar group_ids: The group ids for the private endpoint resource. - :vartype group_ids: list[str] - :ivar private_endpoint: The private endpoint resource. - :vartype private_endpoint: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between service consumer and provider. - :vartype private_link_service_connection_state: - ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"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"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "group_ids": {"key": "properties.groupIds", "type": "[str]"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The private endpoint resource. - :paramtype private_endpoint: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :paramtype private_link_service_connection_state: - ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.group_ids: Optional[list[str]] = None - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """The response of a PrivateEndpointConnection list operation. - - All required parameters must be populated in order to send to server. - - :ivar value: The PrivateEndpointConnection items on this page. Required. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: list["_models.PrivateEndpointConnection"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The PrivateEndpointConnection items on this page. Required. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :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 private link DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"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"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[list[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource private link DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id: Optional[str] = None - self.required_members: Optional[list[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[list["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - 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: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class Server(TrackedResource): - """Represents a 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: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.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 identity: The cmk identity for the server. - :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity - :ivar sku: The SKU (pricing tier) of the server. - :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku - :ivar administrator_login: The administrator's login name of a server. Can only be specified - when the server is being created (and is required for creation). - :vartype administrator_login: str - :ivar administrator_login_password: The password of the administrator login (required for - server creation). - :vartype administrator_login_password: str - :ivar version: Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL - 5.7. Known values are: "5.7" and "8.0.21". - :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion - :ivar full_version: Major version and actual engine version. - :vartype full_version: str - :ivar availability_zone: availability Zone information of the server. - :vartype availability_zone: str - :ivar create_mode: The mode to create a new MySQL server. Known values are: "Default", - "PointInTimeRestore", "Replica", and "GeoRestore". - :vartype create_mode: str or ~azure.mgmt.mysqlflexibleservers.models.CreateMode - :ivar source_server_resource_id: The source MySQL server id. - :vartype source_server_resource_id: str - :ivar restore_point_in_time: Restore point creation time (ISO8601 format), specifying the time - to restore from. - :vartype restore_point_in_time: ~datetime.datetime - :ivar replication_role: The replication role. Known values are: "None", "Source", and - "Replica". - :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole - :ivar replica_capacity: The maximum number of replicas that a primary server can have. - :vartype replica_capacity: int - :ivar data_encryption: The Data Encryption for CMK. - :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption - :ivar state: The state of a server. Known values are: "Ready", "Dropping", "Disabled", - "Starting", "Stopping", "Stopped", and "Updating". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.ServerState - :ivar fully_qualified_domain_name: The fully qualified domain name of a server. - :vartype fully_qualified_domain_name: str - :ivar database_port: The server database port. Can only be specified when the server is being - created. - :vartype database_port: int - :ivar storage: Storage related properties of a server. - :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage - :ivar backup: Backup related properties of a server. - :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup - :ivar high_availability: High availability related properties of a server. - :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability - :ivar network: Network related properties of a server. - :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network - :ivar private_endpoint_connections: PrivateEndpointConnections related properties of a server. - :vartype private_endpoint_connections: - list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] - :ivar maintenance_policy: Maintenance policy of a server. - :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy - :ivar maintenance_window: Maintenance window of a server. Known issue: cannot be set during - server creation or updated with other properties during server update; must be updated - separately. - :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow - :ivar import_source_properties: Source properties for import from storage. - :vartype import_source_properties: - ~azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "full_version": {"readonly": True}, - "replica_capacity": {"readonly": True, "minimum": 0}, - "state": {"readonly": True}, - "fully_qualified_domain_name": {"readonly": True}, - "private_endpoint_connections": {"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"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "identity": {"key": "identity", "type": "MySQLServerIdentity"}, - "sku": {"key": "sku", "type": "MySQLServerSku"}, - "administrator_login": {"key": "properties.administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "full_version": {"key": "properties.fullVersion", "type": "str"}, - "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - "source_server_resource_id": {"key": "properties.sourceServerResourceId", "type": "str"}, - "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, - "replication_role": {"key": "properties.replicationRole", "type": "str"}, - "replica_capacity": {"key": "properties.replicaCapacity", "type": "int"}, - "data_encryption": {"key": "properties.dataEncryption", "type": "DataEncryption"}, - "state": {"key": "properties.state", "type": "str"}, - "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, - "database_port": {"key": "properties.databasePort", "type": "int"}, - "storage": {"key": "properties.storage", "type": "Storage"}, - "backup": {"key": "properties.backup", "type": "Backup"}, - "high_availability": {"key": "properties.highAvailability", "type": "HighAvailability"}, - "network": {"key": "properties.network", "type": "Network"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "maintenance_policy": {"key": "properties.maintenancePolicy", "type": "MaintenancePolicy"}, - "maintenance_window": {"key": "properties.maintenanceWindow", "type": "MaintenanceWindow"}, - "import_source_properties": {"key": "properties.importSourceProperties", "type": "ImportSourceProperties"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.MySQLServerIdentity"] = None, - sku: Optional["_models.MySQLServerSku"] = None, - administrator_login: Optional[str] = None, - administrator_login_password: Optional[str] = None, - version: Optional[Union[str, "_models.ServerVersion"]] = None, - availability_zone: Optional[str] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - source_server_resource_id: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, - data_encryption: Optional["_models.DataEncryption"] = None, - database_port: Optional[int] = None, - storage: Optional["_models.Storage"] = None, - backup: Optional["_models.Backup"] = None, - high_availability: Optional["_models.HighAvailability"] = None, - network: Optional["_models.Network"] = None, - maintenance_policy: Optional["_models.MaintenancePolicy"] = None, - maintenance_window: Optional["_models.MaintenanceWindow"] = None, - import_source_properties: Optional["_models.ImportSourceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword identity: The cmk identity for the server. - :paramtype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity - :keyword sku: The SKU (pricing tier) of the server. - :paramtype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku - :keyword administrator_login: The administrator's login name of a server. Can only be specified - when the server is being created (and is required for creation). - :paramtype administrator_login: str - :keyword administrator_login_password: The password of the administrator login (required for - server creation). - :paramtype administrator_login_password: str - :keyword version: Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL - 5.7. Known values are: "5.7" and "8.0.21". - :paramtype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion - :keyword availability_zone: availability Zone information of the server. - :paramtype availability_zone: str - :keyword create_mode: The mode to create a new MySQL server. Known values are: "Default", - "PointInTimeRestore", "Replica", and "GeoRestore". - :paramtype create_mode: str or ~azure.mgmt.mysqlflexibleservers.models.CreateMode - :keyword source_server_resource_id: The source MySQL server id. - :paramtype source_server_resource_id: str - :keyword restore_point_in_time: Restore point creation time (ISO8601 format), specifying the - time to restore from. - :paramtype restore_point_in_time: ~datetime.datetime - :keyword replication_role: The replication role. Known values are: "None", "Source", and - "Replica". - :paramtype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole - :keyword data_encryption: The Data Encryption for CMK. - :paramtype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption - :keyword database_port: The server database port. Can only be specified when the server is - being created. - :paramtype database_port: int - :keyword storage: Storage related properties of a server. - :paramtype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage - :keyword backup: Backup related properties of a server. - :paramtype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup - :keyword high_availability: High availability related properties of a server. - :paramtype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability - :keyword network: Network related properties of a server. - :paramtype network: ~azure.mgmt.mysqlflexibleservers.models.Network - :keyword maintenance_policy: Maintenance policy of a server. - :paramtype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy - :keyword maintenance_window: Maintenance window of a server. Known issue: cannot be set during - server creation or updated with other properties during server update; must be updated - separately. - :paramtype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow - :keyword import_source_properties: Source properties for import from storage. - :paramtype import_source_properties: - ~azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties - """ - super().__init__(tags=tags, location=location, **kwargs) - self.identity = identity - self.sku = sku - self.administrator_login = administrator_login - self.administrator_login_password = administrator_login_password - self.version = version - self.full_version: Optional[str] = None - self.availability_zone = availability_zone - self.create_mode = create_mode - self.source_server_resource_id = source_server_resource_id - self.restore_point_in_time = restore_point_in_time - self.replication_role = replication_role - self.replica_capacity: Optional[int] = None - self.data_encryption = data_encryption - self.state: Optional[Union[str, "_models.ServerState"]] = None - self.fully_qualified_domain_name: Optional[str] = None - self.database_port = database_port - self.storage = storage - self.backup = backup - self.high_availability = high_availability - self.network = network - self.private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = None - self.maintenance_policy = maintenance_policy - self.maintenance_window = maintenance_window - self.import_source_properties = import_source_properties - - -class ServerBackup(ProxyResource): - """Server backup properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar backup_type: Backup type. - :vartype backup_type: str - :ivar completed_time: Backup completed time (ISO8601 format). - :vartype completed_time: ~datetime.datetime - :ivar source: Backup source. - :vartype source: 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"}, - "backup_type": {"key": "properties.backupType", "type": "str"}, - "completed_time": {"key": "properties.completedTime", "type": "iso-8601"}, - "source": {"key": "properties.source", "type": "str"}, - } - - def __init__( - self, - *, - backup_type: Optional[str] = None, - completed_time: Optional[datetime.datetime] = None, - source: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword backup_type: Backup type. - :paramtype backup_type: str - :keyword completed_time: Backup completed time (ISO8601 format). - :paramtype completed_time: ~datetime.datetime - :keyword source: Backup source. - :paramtype source: str - """ - super().__init__(**kwargs) - self.backup_type = backup_type - self.completed_time = completed_time - self.source = source - - -class ServerBackupListResult(_serialization.Model): - """The response of a ServerBackup list operation. - - :ivar value: The ServerBackup items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ServerBackup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.ServerBackup"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The ServerBackup items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ServerBackupV2(ProxyResource): - """Server backup properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/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.mysqlflexibleservers.models.SystemData - :ivar backup_name_v2: Backup name. - :vartype backup_name_v2: str - :ivar backup_type: "FULL" - :vartype backup_type: str or ~azure.mgmt.mysqlflexibleservers.models.BackupType - :ivar completed_time: Backup completed time (ISO8601 format). - :vartype completed_time: ~datetime.datetime - :ivar source: Backup source. - :vartype source: str - :ivar provisioning_state: The provisioning state of backup resource. Known values are: - "Succeeded", "Creating", "Deleting", "Failed", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.mysqlflexibleservers.models.ProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"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"}, - "backup_name_v2": {"key": "properties.backupNameV2", "type": "str"}, - "backup_type": {"key": "properties.backupType", "type": "str"}, - "completed_time": {"key": "properties.completedTime", "type": "iso-8601"}, - "source": {"key": "properties.source", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - backup_name_v2: Optional[str] = None, - backup_type: Optional[Union[str, "_models.BackupType"]] = None, - completed_time: Optional[datetime.datetime] = None, - source: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword backup_name_v2: Backup name. - :paramtype backup_name_v2: str - :keyword backup_type: "FULL" - :paramtype backup_type: str or ~azure.mgmt.mysqlflexibleservers.models.BackupType - :keyword completed_time: Backup completed time (ISO8601 format). - :paramtype completed_time: ~datetime.datetime - :keyword source: Backup source. - :paramtype source: str - """ - super().__init__(**kwargs) - self.backup_name_v2 = backup_name_v2 - self.backup_type = backup_type - self.completed_time = completed_time - self.source = source - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - - -class ServerBackupV2ListResult(_serialization.Model): - """The response of a ServerBackupV2 list operation. - - :ivar value: The ServerBackupV2 items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ServerBackupV2]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.ServerBackupV2"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The ServerBackupV2 items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ServerDetachVNetParameter(_serialization.Model): - """Parameters to detach Vnet. - - :ivar public_network_access: Whether or not public network access is allowed for this server. - Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and - "Disabled". - :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, *, public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, **kwargs: Any - ) -> None: - """ - :keyword public_network_access: Whether or not public network access is allowed for this - server. Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and - "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class ServerEditionCapability(_serialization.Model): - """Server edition capabilities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Server edition name. - :vartype name: str - :ivar supported_storage_editions: A list of supported storage editions. - :vartype supported_storage_editions: - list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] - :ivar supported_server_versions: A list of supported server versions. - :vartype supported_server_versions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability] - """ - - _validation = { - "name": {"readonly": True}, - "supported_storage_editions": {"readonly": True}, - "supported_server_versions": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_storage_editions": {"key": "supportedStorageEditions", "type": "[StorageEditionCapability]"}, - "supported_server_versions": {"key": "supportedServerVersions", "type": "[ServerVersionCapability]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = None - self.supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = None - - -class ServerEditionCapabilityV2(_serialization.Model): - """Server edition capabilities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Server edition name. - :vartype name: str - :ivar default_sku: Default Sku name. - :vartype default_sku: str - :ivar default_storage_size: Default storage size. - :vartype default_storage_size: int - :ivar supported_storage_editions: A list of supported storage editions. - :vartype supported_storage_editions: - list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] - :ivar supported_skus: A list of supported Skus. - :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2] - """ - - _validation = { - "name": {"readonly": True}, - "default_sku": {"readonly": True}, - "default_storage_size": {"readonly": True}, - "supported_storage_editions": {"readonly": True}, - "supported_skus": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "default_sku": {"key": "defaultSku", "type": "str"}, - "default_storage_size": {"key": "defaultStorageSize", "type": "int"}, - "supported_storage_editions": {"key": "supportedStorageEditions", "type": "[StorageEditionCapability]"}, - "supported_skus": {"key": "supportedSkus", "type": "[SkuCapabilityV2]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.default_sku: Optional[str] = None - self.default_storage_size: Optional[int] = None - self.supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = None - self.supported_skus: Optional[list["_models.SkuCapabilityV2"]] = None - - -class ServerForUpdate(_serialization.Model): - """Parameters allowed to update for a server. - - :ivar identity: The cmk identity for the server. - :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity - :ivar sku: The SKU (pricing tier) of the server. - :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku - :ivar tags: Application-specific metadata in the form of key-value pairs. - :vartype tags: dict[str, str] - :ivar administrator_login_password: The password of the administrator login. - :vartype administrator_login_password: str - :ivar version: Server version. Known values are: "5.7" and "8.0.21". - :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion - :ivar storage: Storage related properties of a server. - :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage - :ivar backup: Backup related properties of a server. - :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup - :ivar high_availability: High availability related properties of a server. - :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability - :ivar maintenance_policy: Maintenance policy of a server. - :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy - :ivar maintenance_window: Maintenance window of a server. - :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow - :ivar replication_role: The replication role of the server. Known values are: "None", "Source", - and "Replica". - :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole - :ivar data_encryption: The Data Encryption for CMK. - :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption - :ivar network: Network related properties of a server. - :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network - """ - - _attribute_map = { - "identity": {"key": "identity", "type": "MySQLServerIdentity"}, - "sku": {"key": "sku", "type": "MySQLServerSku"}, - "tags": {"key": "tags", "type": "{str}"}, - "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "storage": {"key": "properties.storage", "type": "Storage"}, - "backup": {"key": "properties.backup", "type": "Backup"}, - "high_availability": {"key": "properties.highAvailability", "type": "HighAvailability"}, - "maintenance_policy": {"key": "properties.maintenancePolicy", "type": "MaintenancePolicy"}, - "maintenance_window": {"key": "properties.maintenanceWindow", "type": "MaintenanceWindow"}, - "replication_role": {"key": "properties.replicationRole", "type": "str"}, - "data_encryption": {"key": "properties.dataEncryption", "type": "DataEncryption"}, - "network": {"key": "properties.network", "type": "Network"}, - } - - def __init__( - self, - *, - identity: Optional["_models.MySQLServerIdentity"] = None, - sku: Optional["_models.MySQLServerSku"] = None, - tags: Optional[dict[str, str]] = None, - administrator_login_password: Optional[str] = None, - version: Optional[Union[str, "_models.ServerVersion"]] = None, - storage: Optional["_models.Storage"] = None, - backup: Optional["_models.Backup"] = None, - high_availability: Optional["_models.HighAvailability"] = None, - maintenance_policy: Optional["_models.MaintenancePolicy"] = None, - maintenance_window: Optional["_models.MaintenanceWindow"] = None, - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, - data_encryption: Optional["_models.DataEncryption"] = None, - network: Optional["_models.Network"] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: The cmk identity for the server. - :paramtype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity - :keyword sku: The SKU (pricing tier) of the server. - :paramtype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku - :keyword tags: Application-specific metadata in the form of key-value pairs. - :paramtype tags: dict[str, str] - :keyword administrator_login_password: The password of the administrator login. - :paramtype administrator_login_password: str - :keyword version: Server version. Known values are: "5.7" and "8.0.21". - :paramtype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion - :keyword storage: Storage related properties of a server. - :paramtype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage - :keyword backup: Backup related properties of a server. - :paramtype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup - :keyword high_availability: High availability related properties of a server. - :paramtype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability - :keyword maintenance_policy: Maintenance policy of a server. - :paramtype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy - :keyword maintenance_window: Maintenance window of a server. - :paramtype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow - :keyword replication_role: The replication role of the server. Known values are: "None", - "Source", and "Replica". - :paramtype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole - :keyword data_encryption: The Data Encryption for CMK. - :paramtype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption - :keyword network: Network related properties of a server. - :paramtype network: ~azure.mgmt.mysqlflexibleservers.models.Network - """ - super().__init__(**kwargs) - self.identity = identity - self.sku = sku - self.tags = tags - self.administrator_login_password = administrator_login_password - self.version = version - self.storage = storage - self.backup = backup - self.high_availability = high_availability - self.maintenance_policy = maintenance_policy - self.maintenance_window = maintenance_window - self.replication_role = replication_role - self.data_encryption = data_encryption - self.network = network - - -class ServerGtidSetParameter(_serialization.Model): - """Server Gtid set parameters: Replication with Global Transaction Identifiers. - - :ivar gtid_set: The Gtid set of server. - :vartype gtid_set: str - """ - - _attribute_map = { - "gtid_set": {"key": "gtidSet", "type": "str"}, - } - - def __init__(self, *, gtid_set: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword gtid_set: The Gtid set of server. - :paramtype gtid_set: str - """ - super().__init__(**kwargs) - self.gtid_set = gtid_set - - -class ServerListResult(_serialization.Model): - """The response of a Server list operation. - - :ivar value: The Server items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Server] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Server]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[list["_models.Server"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The Server items on this page. - :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Server] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ServerRestartParameter(_serialization.Model): - """Server restart parameters. - - :ivar restart_with_failover: Whether or not failover to standby server when restarting a server - with high availability enabled. Known values are: "Enabled" and "Disabled". - :vartype restart_with_failover: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar max_failover_seconds: The maximum allowed failover time in seconds. - :vartype max_failover_seconds: int - """ - - _attribute_map = { - "restart_with_failover": {"key": "restartWithFailover", "type": "str"}, - "max_failover_seconds": {"key": "maxFailoverSeconds", "type": "int"}, - } - - def __init__( - self, - *, - restart_with_failover: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - max_failover_seconds: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword restart_with_failover: Whether or not failover to standby server when restarting a - server with high availability enabled. Known values are: "Enabled" and "Disabled". - :paramtype restart_with_failover: str or - ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :keyword max_failover_seconds: The maximum allowed failover time in seconds. - :paramtype max_failover_seconds: int - """ - super().__init__(**kwargs) - self.restart_with_failover = restart_with_failover - self.max_failover_seconds = max_failover_seconds - - -class ServerVersionCapability(_serialization.Model): - """Server version capabilities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: server version. - :vartype name: str - :ivar supported_skus: A list of supported Skus. - :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapability] - """ - - _validation = { - "name": {"readonly": True}, - "supported_skus": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_skus": {"key": "supportedSkus", "type": "[SkuCapability]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.supported_skus: Optional[list["_models.SkuCapability"]] = None - - -class ServerVersionCapabilityV2(_serialization.Model): - """Server version capabilities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: server version. - :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 SkuCapability(_serialization.Model): - """Sku capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: vCore name. - :vartype name: str - :ivar v_cores: supported vCores. - :vartype v_cores: int - :ivar supported_iops: supported IOPS. - :vartype supported_iops: int - :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. - :vartype supported_memory_per_v_core_mb: int - """ - - _validation = { - "name": {"readonly": True}, - "v_cores": {"readonly": True}, - "supported_iops": {"readonly": True}, - "supported_memory_per_v_core_mb": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "v_cores": {"key": "vCores", "type": "int"}, - "supported_iops": {"key": "supportedIops", "type": "int"}, - "supported_memory_per_v_core_mb": {"key": "supportedMemoryPerVCoreMB", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.v_cores: Optional[int] = None - self.supported_iops: Optional[int] = None - self.supported_memory_per_v_core_mb: Optional[int] = None - - -class SkuCapabilityV2(_serialization.Model): - """Sku capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: vCore name. - :vartype name: str - :ivar v_cores: supported vCores. - :vartype v_cores: int - :ivar supported_iops: supported IOPS. - :vartype supported_iops: int - :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. - :vartype supported_memory_per_v_core_mb: int - :ivar supported_zones: Supported zones. - :vartype supported_zones: list[str] - :ivar supported_ha_mode: Supported high availability mode. - :vartype supported_ha_mode: list[str] - """ - - _validation = { - "name": {"readonly": True}, - "v_cores": {"readonly": True}, - "supported_iops": {"readonly": True}, - "supported_memory_per_v_core_mb": {"readonly": True}, - "supported_zones": {"readonly": True}, - "supported_ha_mode": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "v_cores": {"key": "vCores", "type": "int"}, - "supported_iops": {"key": "supportedIops", "type": "int"}, - "supported_memory_per_v_core_mb": {"key": "supportedMemoryPerVCoreMB", "type": "int"}, - "supported_zones": {"key": "supportedZones", "type": "[str]"}, - "supported_ha_mode": {"key": "supportedHAMode", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.v_cores: Optional[int] = None - self.supported_iops: Optional[int] = None - self.supported_memory_per_v_core_mb: Optional[int] = None - self.supported_zones: Optional[list[str]] = None - self.supported_ha_mode: Optional[list[str]] = None - - -class Storage(_serialization.Model): - """Storage Profile properties of a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar storage_size_gb: Max storage size allowed for a server. - :vartype storage_size_gb: int - :ivar iops: Storage IOPS for a server. - :vartype iops: int - :ivar auto_grow: Enable Storage Auto Grow or not. Known values are: "Enabled" and "Disabled". - :vartype auto_grow: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar log_on_disk: Enable Log On Disk or not. Known values are: "Enabled" and "Disabled". - :vartype log_on_disk: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar storage_sku: The sku name of the server storage. - :vartype storage_sku: str - :ivar auto_io_scaling: Enable IO Auto Scaling or not. Known values are: "Enabled" and - "Disabled". - :vartype auto_io_scaling: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar storage_redundancy: The redundant type of the server storage. The parameter is used for - server creation. Known values are: "LocalRedundancy" and "ZoneRedundancy". - :vartype storage_redundancy: str or - ~azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum - """ - - _validation = { - "storage_sku": {"readonly": True}, - } - - _attribute_map = { - "storage_size_gb": {"key": "storageSizeGB", "type": "int"}, - "iops": {"key": "iops", "type": "int"}, - "auto_grow": {"key": "autoGrow", "type": "str"}, - "log_on_disk": {"key": "logOnDisk", "type": "str"}, - "storage_sku": {"key": "storageSku", "type": "str"}, - "auto_io_scaling": {"key": "autoIoScaling", "type": "str"}, - "storage_redundancy": {"key": "storageRedundancy", "type": "str"}, - } - - def __init__( - self, - *, - storage_size_gb: Optional[int] = None, - iops: Optional[int] = None, - auto_grow: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - log_on_disk: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - auto_io_scaling: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - storage_redundancy: Union[str, "_models.StorageRedundancyEnum"] = "LocalRedundancy", - **kwargs: Any - ) -> None: - """ - :keyword storage_size_gb: Max storage size allowed for a server. - :paramtype storage_size_gb: int - :keyword iops: Storage IOPS for a server. - :paramtype iops: int - :keyword auto_grow: Enable Storage Auto Grow or not. Known values are: "Enabled" and - "Disabled". - :paramtype auto_grow: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :keyword log_on_disk: Enable Log On Disk or not. Known values are: "Enabled" and "Disabled". - :paramtype log_on_disk: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :keyword auto_io_scaling: Enable IO Auto Scaling or not. Known values are: "Enabled" and - "Disabled". - :paramtype auto_io_scaling: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :keyword storage_redundancy: The redundant type of the server storage. The parameter is used - for server creation. Known values are: "LocalRedundancy" and "ZoneRedundancy". - :paramtype storage_redundancy: str or - ~azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum - """ - super().__init__(**kwargs) - self.storage_size_gb = storage_size_gb - self.iops = iops - self.auto_grow = auto_grow - self.log_on_disk = log_on_disk - self.storage_sku: Optional[str] = None - self.auto_io_scaling = auto_io_scaling - self.storage_redundancy = storage_redundancy - - -class StorageEditionCapability(_serialization.Model): - """storage edition capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: storage edition name. - :vartype name: str - :ivar min_storage_size: The minimal supported storage size. - :vartype min_storage_size: int - :ivar max_storage_size: The maximum supported storage size. - :vartype max_storage_size: int - :ivar min_backup_retention_days: Minimal backup retention days. - :vartype min_backup_retention_days: int - :ivar max_backup_retention_days: Maximum backup retention days. - :vartype max_backup_retention_days: int - :ivar min_backup_interval_hours: Minimal backup interval hours. - :vartype min_backup_interval_hours: int - :ivar max_backup_interval_hours: Maximum backup interval hours. - :vartype max_backup_interval_hours: int - """ - - _validation = { - "name": {"readonly": True}, - "min_storage_size": {"readonly": True}, - "max_storage_size": {"readonly": True}, - "min_backup_retention_days": {"readonly": True}, - "max_backup_retention_days": {"readonly": True}, - "min_backup_interval_hours": {"readonly": True}, - "max_backup_interval_hours": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "min_storage_size": {"key": "minStorageSize", "type": "int"}, - "max_storage_size": {"key": "maxStorageSize", "type": "int"}, - "min_backup_retention_days": {"key": "minBackupRetentionDays", "type": "int"}, - "max_backup_retention_days": {"key": "maxBackupRetentionDays", "type": "int"}, - "min_backup_interval_hours": {"key": "minBackupIntervalHours", "type": "int"}, - "max_backup_interval_hours": {"key": "maxBackupIntervalHours", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.min_storage_size: Optional[int] = None - self.max_storage_size: Optional[int] = None - self.min_backup_retention_days: Optional[int] = None - self.max_backup_retention_days: Optional[int] = None - self.min_backup_interval_hours: Optional[int] = None - self.max_backup_interval_hours: Optional[int] = 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.mysqlflexibleservers.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.mysqlflexibleservers.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.mysqlflexibleservers.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.mysqlflexibleservers.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 UserAssignedIdentity(_serialization.Model): - """Metadata of user assigned identity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: Principal Id of user assigned identity. - :vartype principal_id: str - :ivar client_id: Client Id of user assigned identity. - :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 ValidateBackupResponse(_serialization.Model): - """Represents ValidateBackup API Response. - - :ivar number_of_containers: Estimated no of storage containers required for resource data to be - backed up. - :vartype number_of_containers: int - """ - - _attribute_map = { - "number_of_containers": {"key": "properties.numberOfContainers", "type": "int"}, - } - - def __init__(self, *, number_of_containers: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword number_of_containers: Estimated no of storage containers required for resource data to - be backed up. - :paramtype number_of_containers: int - """ - super().__init__(**kwargs) - self.number_of_containers = number_of_containers - - -class VirtualNetworkSubnetUsageParameter(_serialization.Model): - """Virtual network subnet usage parameter. - - :ivar virtual_network_resource_id: Virtual network resource id. - :vartype virtual_network_resource_id: str - """ - - _attribute_map = { - "virtual_network_resource_id": {"key": "virtualNetworkResourceId", "type": "str"}, - } - - def __init__(self, *, virtual_network_resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword virtual_network_resource_id: Virtual network resource id. - :paramtype virtual_network_resource_id: str - """ - super().__init__(**kwargs) - self.virtual_network_resource_id = virtual_network_resource_id - - -class VirtualNetworkSubnetUsageResult(_serialization.Model): - """Virtual network subnet usage data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location name. - :vartype location: str - :ivar subscription_id: The subscription id. - :vartype subscription_id: str - :ivar delegated_subnets_usage: A list of delegated subnet usage. - :vartype delegated_subnets_usage: - list[~azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage] - """ - - _validation = { - "location": {"readonly": True}, - "subscription_id": {"readonly": True}, - "delegated_subnets_usage": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "delegated_subnets_usage": {"key": "delegatedSubnetsUsage", "type": "[DelegatedSubnetUsage]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.subscription_id: Optional[str] = None - self.delegated_subnets_usage: Optional[list["_models.DelegatedSubnetUsage"]] = None diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/__init__.py index f9cdf4c5b3fd..d833fa5e1131 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/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,61 +12,61 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._get_private_dns_zone_suffix_operations import GetPrivateDnsZoneSuffixOperations # type: ignore from ._operations import Operations # type: ignore -from ._check_name_availability_without_location_operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore -from ._servers_operations import ServersOperations # type: ignore -from ._location_based_capabilities_operations import LocationBasedCapabilitiesOperations # type: ignore -from ._location_based_capability_set_operations import LocationBasedCapabilitySetOperations # type: ignore -from ._check_name_availability_operations import CheckNameAvailabilityOperations # type: ignore -from ._check_virtual_network_subnet_usage_operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore -from ._operation_progress_operations import OperationProgressOperations # type: ignore -from ._operation_results_operations import OperationResultsOperations # type: ignore -from ._azure_ad_administrators_operations import AzureADAdministratorsOperations # type: ignore -from ._advanced_threat_protection_settings_operations import AdvancedThreatProtectionSettingsOperations # type: ignore -from ._backup_and_export_operations import BackupAndExportOperations # type: ignore -from ._backups_operations import BackupsOperations # type: ignore -from ._long_running_backups_operations import LongRunningBackupsOperations # type: ignore -from ._long_running_backup_operations import LongRunningBackupOperations # type: ignore -from ._configurations_operations import ConfigurationsOperations # type: ignore -from ._servers_migration_operations import ServersMigrationOperations # type: ignore -from ._databases_operations import DatabasesOperations # type: ignore -from ._firewall_rules_operations import FirewallRulesOperations # type: ignore -from ._log_files_operations import LogFilesOperations # type: ignore -from ._maintenances_operations import MaintenancesOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._replicas_operations import ReplicasOperations # type: ignore +from ._operations import AzureADAdministratorsOperations # type: ignore +from ._operations import ServersOperations # type: ignore +from ._operations import BackupAndExportOperations # type: ignore +from ._operations import LogFilesOperations # type: ignore +from ._operations import ServersMigrationOperations # type: ignore +from ._operations import BackupsOperations # type: ignore +from ._operations import LongRunningBackupsOperations # type: ignore +from ._operations import LongRunningBackupOperations # type: ignore +from ._operations import ConfigurationsOperations # type: ignore +from ._operations import DatabasesOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import AdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import LocationBasedCapabilitySetOperations # type: ignore +from ._operations import MaintenancesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import LocationBasedCapabilitiesOperations # type: ignore +from ._operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore +from ._operations import CheckNameAvailabilityOperations # type: ignore +from ._operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore +from ._operations import OperationResultsOperations # type: ignore +from ._operations import OperationProgressOperations # type: ignore +from ._operations import GetPrivateDnsZoneSuffixOperations # type: ignore +from ._operations import ReplicasOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "GetPrivateDnsZoneSuffixOperations", "Operations", - "CheckNameAvailabilityWithoutLocationOperations", - "ServersOperations", - "LocationBasedCapabilitiesOperations", - "LocationBasedCapabilitySetOperations", - "CheckNameAvailabilityOperations", - "CheckVirtualNetworkSubnetUsageOperations", - "OperationProgressOperations", - "OperationResultsOperations", "AzureADAdministratorsOperations", - "AdvancedThreatProtectionSettingsOperations", + "ServersOperations", "BackupAndExportOperations", + "LogFilesOperations", + "ServersMigrationOperations", "BackupsOperations", "LongRunningBackupsOperations", "LongRunningBackupOperations", "ConfigurationsOperations", - "ServersMigrationOperations", "DatabasesOperations", "FirewallRulesOperations", - "LogFilesOperations", + "AdvancedThreatProtectionSettingsOperations", + "LocationBasedCapabilitySetOperations", "MaintenancesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "LocationBasedCapabilitiesOperations", + "CheckVirtualNetworkSubnetUsageOperations", + "CheckNameAvailabilityOperations", + "CheckNameAvailabilityWithoutLocationOperations", + "OperationResultsOperations", + "OperationProgressOperations", + "GetPrivateDnsZoneSuffixOperations", "ReplicasOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py deleted file mode 100644 index faf27e0567ff..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,840 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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(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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.AdvancedThreatProtection"]: - """Gets a list of 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 either AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.AdvancedThreatProtection: - """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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :return: AdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdvancedThreatProtection] = 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_put_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, 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", self._config.api_version)) - 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, "AdvancedThreatProtection") - - _request = build_update_put_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, 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 == 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.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_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_put( - 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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is either a - AdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or IO[bytes] - :return: An instance of LROPoller that returns either AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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_put_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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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", self._config.api_version)) - 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, "AdvancedThreatProtectionForUpdate") - - _request = build_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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtectionForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate - :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is either a - AdvancedThreatProtectionForUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either AdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - 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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py deleted file mode 100644 index 62787940ed37..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py +++ /dev/null @@ -1,730 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.AzureADAdministrator"]: - """List all the AAD administrators in 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 - :return: An iterator like instance of either AzureADAdministrator or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - 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, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> _models.AzureADAdministrator: - """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :return: AzureADAdministrator or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AzureADAdministrator] = 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureADAdministrator", 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.AzureADAdministrator, 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", self._config.api_version)) - 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, "AzureADAdministrator") - - _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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_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.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, - administrator_name: Union[str, _models.AdministratorName], - parameters: _models.AzureADAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :keyword content_type: Body Parameter 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 AzureADAdministrator or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: IO[bytes] - :keyword content_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 AzureADAdministrator or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. Is - either a AzureADAdministrator type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or IO[bytes] - :return: An instance of LROPoller that returns either AzureADAdministrator or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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("AzureADAdministrator", 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.AzureADAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureADAdministrator]( - 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", self._config.api_version)) - 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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> LROPoller[None]: - """Deletes an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py deleted file mode 100644 index 398500f460a0..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py +++ /dev/null @@ -1,403 +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 MySQLManagementClientConfiguration -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", "2024-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/backupAndExport", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/validateBackup", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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.BackupAndExportRequest, 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", self._config.api_version)) - 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, "BackupAndExportRequest") - - _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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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( - self, - resource_group_name: str, - server_name: str, - parameters: _models.BackupAndExportRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest - :keyword content_type: Body Parameter 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 BackupAndExportResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: IO[bytes] - :keyword content_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 BackupAndExportResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupAndExportRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Is either a BackupAndExportRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or IO[bytes] - :return: An instance of LROPoller that returns either BackupAndExportResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupAndExportResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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): - deserialized = self._deserialize("BackupAndExportResponse", 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.BackupAndExportResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.BackupAndExportResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def validate_backup( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> _models.ValidateBackupResponse: - """Validates if backup can be performed for 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 - :return: ValidateBackupResponse or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) - - _request = build_validate_backup_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateBackupResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_operations.py deleted file mode 100644 index 7ea80f19bbeb..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_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, Optional, TypeVar -import urllib.parse - -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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.ServerBackup"]: - """List all the backups 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 - :return: An iterator like instance of either ServerBackup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerBackupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, backup_name: str, **kwargs: Any) -> _models.ServerBackup: - """List all the backups 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_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("ServerBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def put(self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any) -> _models.ServerBackup: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_put_request( - resource_group_name=resource_group_name, - server_name=server_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("ServerBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py deleted file mode 100644 index 95d656113bff..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py +++ /dev/null @@ -1,210 +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 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 MySQLManagementClientConfiguration -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(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", "2024-12-30")) - 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.DBforMySQL/locations/{locationName}/checkNameAvailability", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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 CheckNameAvailabilityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, - location_name: str, - name_availability_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def execute( - self, - location_name: str, - name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or - a IO[bytes] type. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") - - _request = build_execute_request( - location_name=location_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_operations.py deleted file mode 100644 index c9f5d64c64a1..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_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 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 MySQLManagementClientConfiguration -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(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/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) - - -class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`check_name_availability_without_location` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def execute( - self, name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or - a IO[bytes] type. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] - :return: NameAvailability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") - - _request = build_execute_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("NameAvailability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py deleted file mode 100644 index 3f833bcb7ad2..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py +++ /dev/null @@ -1,205 +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 MySQLManagementClientConfiguration -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(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", "2024-12-30")) - 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.DBforMySQL/locations/{locationName}/checkVirtualNetworkSubnetUsage", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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 CheckVirtualNetworkSubnetUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - parameters: _models.VirtualNetworkSubnetUsageParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :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: VirtualNetworkSubnetUsageResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def execute( - self, - location_name: str, - parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Is either a VirtualNetworkSubnetUsageParameter type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or - IO[bytes] - :return: VirtualNetworkSubnetUsageResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") - - _request = build_execute_request( - location_name=location_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualNetworkSubnetUsageResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py deleted file mode 100644 index 103204d844d0..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py +++ /dev/null @@ -1,1075 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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, - *, - tags: Optional[str] = None, - keyword: Optional[str] = None, - page: Optional[int] = None, - page_size: 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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/updateConfigurations", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, - tags: Optional[str] = None, - keyword: Optional[str] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.Configuration"]: - """List all the configurations in 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 tags: The tags of the server configuration. Default value is None. - :type tags: str - :param keyword: The keyword of the server configuration. Default value is None. - :type keyword: str - :param page: The page of the server configuration. Default value is None. - :type page: int - :param page_size: The pageSize of the server configuration. Default value is None. - :type page_size: int - :return: An iterator like instance of either Configuration or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - tags=tags, - keyword=keyword, - page=page, - page_size=page_size, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ConfigurationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, configuration_name: str, **kwargs: Any - ) -> _models.Configuration: - """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :return: Configuration or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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("Configuration", 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, - configuration_name: str, - parameters: Union[_models.Configuration, 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", self._config.api_version)) - 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, "Configuration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter 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 Configuration or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is either a - Configuration type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, 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", self._config.api_version)) - 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, "Configuration") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter 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 Configuration or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is either a - Configuration type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] - :return: An instance of LROPoller that returns either Configuration or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _batch_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, 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", self._config.api_version)) - 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, "ConfigurationListForBatchUpdate") - - _request = build_batch_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ConfigurationListForBatchUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate - :keyword content_type: Body Parameter 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 ConfigurationListResult or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 ConfigurationListResult or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Is either a - ConfigurationListForBatchUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either ConfigurationListResult or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._batch_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("ConfigurationListResult", 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.ConfigurationListResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConfigurationListResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py deleted file mode 100644 index 7bc5d22f32da..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py +++ /dev/null @@ -1,694 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/databases", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/databases/{databaseName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/databases/{databaseName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/databases/{databaseName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Database"]: - """List all the databases in 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 - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - 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, **kwargs: Any) -> _models.Database: - """Gets information about 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: Database or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - 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("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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_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.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, - 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 required parameters for creating or updating a database. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: 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 required parameters for creating or updating a database. Is either a - Database type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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": "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 _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", self._config.api_version)) - 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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, database_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - 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 diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py deleted file mode 100644 index 31c8327b0589..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py +++ /dev/null @@ -1,705 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/firewallRules", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.FirewallRule"]: - """List all the firewall rules in 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 - :return: An iterator like instance of either FirewallRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - 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, firewall_rule_name: str, **kwargs: Any - ) -> _models.FirewallRule: - """Gets information about a server 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 server firewall rule. Required. - :type firewall_rule_name: str - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("FirewallRule", 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, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, 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", self._config.api_version)) - 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, "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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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 == 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.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, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of LROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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 - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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: An instance of LROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or IO[bytes] - :return: An instance of LROPoller that returns either FirewallRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - firewall_rule_name=firewall_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("FirewallRule", 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.FirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, firewall_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", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, firewall_rule_name: str, **kwargs: Any - ) -> LROPoller[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 server firewall rule. Required. - :type firewall_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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py deleted file mode 100644 index fc13c54ddc55..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py +++ /dev/null @@ -1,125 +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.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 MySQLManagementClientConfiguration -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(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix") - - # 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 GetPrivateDnsZoneSuffixOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: - """Get private DNS zone suffix in the cloud. - - :return: GetPrivateDnsZoneSuffixResponse or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) - - _request = build_execute_request( - 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("GetPrivateDnsZoneSuffixResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py deleted file mode 100644 index 9fc5b19d247c..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py +++ /dev/null @@ -1,168 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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(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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilities", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_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 LocationBasedCapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> ItemPaged["_models.CapabilityProperties"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either CapabilityProperties or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilitiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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( - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilitiesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py deleted file mode 100644 index 0563195d65e4..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py +++ /dev/null @@ -1,258 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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(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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_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, subscription_id: str, capability_set_name: str = "default", **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets/{capabilitySetName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), - "capabilitySetName": _SERIALIZER.url( - "capability_set_name", capability_set_name, "str", pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CapabilitySetsList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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( - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilitySetsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, capability_set_name: str = "default", **kwargs: Any) -> _models.Capability: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :param capability_set_name: Name of capability set. Default value is "default". - :type capability_set_name: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Capability] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - capability_set_name=capability_set_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Capability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py deleted file mode 100644 index 0e853ab2c347..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py +++ /dev/null @@ -1,178 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/logFiles", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: - """List all the server log files in 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 - :return: An iterator like instance of either LogFile or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.LogFileListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("LogFileListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py deleted file mode 100644 index 0a3c397a1ea6..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py +++ /dev/null @@ -1,325 +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 MySQLManagementClientConfiguration -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, 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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ServerBackupV2") - else: - _json = None - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_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, 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 == 201: - 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.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( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[_models.ServerBackupV2] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :keyword content_type: Body Parameter 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 ServerBackupV2 or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: IO[bytes] - :keyword content_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 ServerBackupV2 or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Is either a ServerBackupV2 type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or IO[bytes] - :return: An instance of LROPoller that returns either ServerBackupV2 or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - 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("ServerBackupV2", 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.ServerBackupV2].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerBackupV2]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_operations.py deleted file mode 100644 index a77493a5ee83..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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(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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.ServerBackupV2"]: - """List all the backups 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 - :return: An iterator like instance of either ServerBackupV2 or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackupV2ListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerBackupV2ListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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, backup_name: str, **kwargs: Any - ) -> _models.ServerBackupV2: - """Get backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackupV2 or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_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("ServerBackupV2", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py deleted file mode 100644 index 603d80f4a298..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py +++ /dev/null @@ -1,542 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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(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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Maintenance"]: - """List maintenances. - - :param resource_group_name: The name of the resource group. 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 either Maintenance or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.MaintenanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MaintenanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_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 read( - self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any - ) -> _models.Maintenance: - """Read maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :return: Maintenance or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - - _request = build_read_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_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("Maintenance", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "MaintenanceUpdate") - else: - _json = None - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, - maintenance_name: str, - parameters: Optional[_models.MaintenanceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate - :keyword content_type: Body Parameter 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 Maintenance or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: IO[bytes] - :keyword content_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 Maintenance or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Is either a - MaintenanceUpdate type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Maintenance or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - maintenance_name=maintenance_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("Maintenance", 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.Maintenance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Maintenance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py deleted file mode 100644 index 5eba7e5a3a1c..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py +++ /dev/null @@ -1,145 +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 MySQLManagementClientConfiguration -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, 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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationProgress/{operationId}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_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 OperationProgressOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationProgressResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) - - _request = build_get_request( - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationProgressResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py deleted file mode 100644 index fd504c84853b..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py +++ /dev/null @@ -1,145 +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 MySQLManagementClientConfiguration -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, 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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationResults/{operationId}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_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 OperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationStatusExtendedResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) - - _request = build_get_request( - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusExtendedResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py index d457c2aa58fa..eb6cfa8c79cd 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py @@ -1,12 +1,15 @@ +# 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 +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import PipelineClient @@ -16,36 +19,1910 @@ 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 MySQLManagementClientConfiguration +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", "2024-12-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.DBforMySQL/operations") + _url = "/providers/Microsoft.DBforMySQL/operations" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_servers_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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers" + 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_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/flexibleServers" + 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_servers_failover_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/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"), + } + + _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_servers_validate_estimate_high_availability_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/validateEstimateHighAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_restart_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/restart" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_servers_start_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/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"), + } + + _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_servers_stop_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/stop" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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="POST", url=_url, params=_params, **kwargs) + + +def build_servers_reset_gtid_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/resetGtid" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_servers_detach_v_net_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/detachVNet" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_backup_and_export_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupAndExport" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_backup_and_export_validate_backup_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/validateBackup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_log_files_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/logFiles" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_migration_cutover_migration_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/cutoverMigration" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_backups_get_request( + resource_group_name: str, server_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_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_backups_put_request( + resource_group_name: str, server_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backups_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_long_running_backups_get_request( + resource_group_name: str, server_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_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_running_backups_list_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_long_running_backup_create_request( + resource_group_name: str, server_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_running_backup_delete_request( + resource_group_name: str, server_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_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_configurations_get_request( + resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configurations_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, configuration_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.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_configurations_update_request( + resource_group_name: str, server_name: str, configuration_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_configurations_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + tags: Optional[str] = None, + keyword: Optional[str] = None, + page: Optional[int] = None, + page_size: 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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 tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + if keyword is not None: + _params["keyword"] = _SERIALIZER.query("keyword", keyword, "str") + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int") + if page_size is not None: + _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configurations_batch_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/updateConfigurations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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_databases_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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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 + _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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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") + + # 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_advanced_threat_protection_settings_update_put_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_advanced_threat_protection_settings_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_advanced_threat_protection_settings_list_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_location_based_capability_set_get_request( # pylint: disable=name-too-long + location_name: str, capability_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets/{capabilitySetName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "capabilitySetName": _SERIALIZER.url("capability_set_name", capability_set_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_location_based_capability_set_list_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets" + 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_maintenances_read_request( + resource_group_name: str, server_name: str, maintenance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "maintenanceName": _SERIALIZER.url("maintenance_name", maintenance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_maintenances_update_request( + resource_group_name: str, server_name: str, maintenance_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "maintenanceName": _SERIALIZER.url("maintenance_name", maintenance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_maintenances_list_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_location_based_capabilities_list_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_virtual_network_subnet_usage_execute_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 {}) + + 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/checkVirtualNetworkSubnetUsage" + 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 + if content_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_check_name_availability_execute_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 {}) + + 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/checkNameAvailability" + ) + 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 + if content_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_check_name_availability_without_location_execute_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/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_operation_results_get_request( + 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationResults/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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_operation_progress_get_request( + 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationProgress/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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_get_private_dns_zone_suffix_execute_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix" + + # 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_replicas_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/replicas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.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") @@ -63,10 +1940,8840 @@ class Operations: Instead, you should access the following operations through :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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 AzureADAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.AzureADAdministrator: + """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :return: AzureADAdministrator. The AzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) + + _request = build_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) + + _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() + else: + deserialized = _deserialize(_models.AzureADAdministrator, 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.AzureADAdministrator, 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_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) + + _stream = True + pipeline_response: PipelineResponse = 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 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.AzureADAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AzureADAdministrator. The AzureADAdministrator + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: 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 AzureADAdministrator. The AzureADAdministrator + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: IO[bytes] + :keyword content_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 AzureADAdministrator. The AzureADAdministrator + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. Is + one of the following types: AzureADAdministrator, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or JSON or + IO[bytes] + :return: An instance of LROPoller that returns AzureADAdministrator. The AzureADAdministrator + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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.AzureADAdministrator, 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.AzureADAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureADAdministrator]( + 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_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) + + _stream = True + pipeline_response: PipelineResponse = self._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 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 an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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.AzureADAdministrator"]: + """List all the AAD administrators in 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 + :return: An iterator like instance of AzureADAdministrator + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AzureADAdministrator]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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.AzureADAdministrator], 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: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Server: + """Gets information about 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: Server. The Server is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Server, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_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_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) + + _stream = True + pipeline_response: PipelineResponse = 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 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.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] + :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[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: 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.mysqlflexibleservers.models.Server] + :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[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Is one of the + following types: Server, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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_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.ServerForUpdate, 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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 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.ServerForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate + :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is one of the following + types: ServerForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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) + + _stream = True + pipeline_response: PipelineResponse = self._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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + 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, **kwargs: Any) -> ItemPaged["_models.Server"]: + """List all the servers in a given 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 Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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, **kwargs: Any) -> ItemPaged["_models.Server"]: + """List all the servers in a given subscription. + + :return: An iterator like instance of Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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 _failover_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_failover_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 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, **kwargs: Any) -> LROPoller[None]: + """Manual failover 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._failover_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 + + @overload + def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: _models.HighAvailabilityValidationEstimation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.HighAvailabilityValidationEstimation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is + one of the following types: HighAvailabilityValidationEstimation, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + or JSON or IO[bytes] + :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~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.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) + + content_type = content_type or "application/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_validate_estimate_high_availability_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) + + _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() + else: + deserialized = _deserialize(_models.HighAvailabilityValidationEstimation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _restart_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, 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_restart_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_restart( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerRestartParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter + :keyword content_type: Body Parameter 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: IO[bytes] + :keyword content_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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Restarts 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 required parameters for restarting a server. Is one of the following + types: ServerRestartParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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._restart_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 + + def _start_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_start_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Starts 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._start_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 + + def _stop_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_stop_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Stops 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._stop_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 + + def _reset_gtid_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, 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_reset_gtid_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerGtidSetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter + :keyword content_type: Body Parameter 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: IO[bytes] + :keyword content_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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Is one of the + following types: ServerGtidSetParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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._reset_gtid_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 + + def _detach_v_net_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, 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_detach_v_net_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerDetachVNetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter + :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: 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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Is one of the following + types: ServerDetachVNetParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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._detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Server, 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.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 + ) + + +class BackupAndExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`backup_and_export` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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.BackupAndExportRequest, 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_and_export_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 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.BackupAndExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: 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 BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: IO[bytes] + :keyword content_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 BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupAndExportRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Is one of the following types: BackupAndExportRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or JSON or + IO[bytes] + :return: An instance of LROPoller that returns BackupAndExportResponse. The + BackupAndExportResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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.BackupAndExportResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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): + 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.BackupAndExportResponse, 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.BackupAndExportResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupAndExportResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def validate_backup( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> _models.ValidateBackupResponse: + """Validates if backup can be performed for 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 + :return: ValidateBackupResponse. The ValidateBackupResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) + + _request = build_backup_and_export_validate_backup_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) + + _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() + else: + deserialized = _deserialize(_models.ValidateBackupResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class LogFilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`log_files` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: + """List all the server log files in 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 + :return: An iterator like instance of LogFile + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LogFile]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_log_files_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.LogFile], 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 ServersMigrationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`servers_migration` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 _cutover_migration_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_migration_cutover_migration_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_cutover_migration( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> LROPoller[_models.Server]: + """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible + 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 Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Server, 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.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 + ) + + +class BackupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, backup_name: str, **kwargs: Any) -> _models.ServerBackup: + """List all the backups 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup. The ServerBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_backups_get_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _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() + else: + deserialized = _deserialize(_models.ServerBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def put(self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any) -> _models.ServerBackup: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup. The ServerBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_backups_put_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _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() + else: + deserialized = _deserialize(_models.ServerBackup, 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.ServerBackup"]: + """List all the backups 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 + :return: An iterator like instance of ServerBackup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_backups_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.ServerBackup], 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 LongRunningBackupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`long_running_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, backup_name: str, **kwargs: Any + ) -> _models.ServerBackupV2: + """Get backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackupV2. The ServerBackupV2 is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + + _request = build_long_running_backups_get_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _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() + else: + deserialized = _deserialize(_models.ServerBackupV2, 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, **kwargs: Any) -> ItemPaged["_models.ServerBackupV2"]: + """List all the backups 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 + :return: An iterator like instance of ServerBackupV2 + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerBackupV2]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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_running_backups_list_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.ServerBackupV2], 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 LongRunningBackupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`long_running_backup` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_long_running_backup_create_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _stream = True + pipeline_response: PipelineResponse = 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["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 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, + backup_name: str, + parameters: Optional[_models.ServerBackupV2] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerBackupV2. The ServerBackupV2 is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: 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 ServerBackupV2. The ServerBackupV2 is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: IO[bytes] + :keyword content_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 ServerBackupV2. The ServerBackupV2 is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Is one of the following types: ServerBackupV2, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerBackupV2. The ServerBackupV2 is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :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)) + content_type = content_type if parameters else None + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + 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.ServerBackupV2, 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.ServerBackupV2].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerBackupV2]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-06-01-preview", + params_added_on={ + "2025-06-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "server_name", + "backup_name", + ] + }, + api_versions_list=["2025-06-01-preview"], + ) + def _delete_initial( + self, resource_group_name: str, server_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_running_backup_delete_request( + resource_group_name=resource_group_name, + server_name=server_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-06-01-preview", + params_added_on={ + "2025-06-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "server_name", + "backup_name", + ] + }, + api_versions_list=["2025-06-01-preview"], + ) + def begin_delete( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete backup for a given server with specified backup 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 backup_name: The name of the backup. 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( + resource_group_name=resource_group_name, + server_name=server_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 + + +class ConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, configuration_name: str, **kwargs: Any + ) -> _models.Configuration: + """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :return: Configuration. The Configuration is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + + _request = build_configurations_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Configuration, 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, + configuration_name: str, + parameters: Union[_models.Configuration, 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_configurations_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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 = True + pipeline_response: PipelineResponse = self._client._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 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: 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 Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is one of the + following types: Configuration, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :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.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, 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_configurations_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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 = True + pipeline_response: PipelineResponse = self._client._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 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: 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 Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is one of the + following types: Configuration, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] + :return: An instance of LROPoller that returns Configuration. The Configuration is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :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.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Configuration]( + 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, + *, + tags: Optional[str] = None, + keyword: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.Configuration"]: + """List all the configurations in 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 + :keyword tags: The tags of the server configuration. Default value is None. + :paramtype tags: str + :keyword keyword: The keyword of the server configuration. Default value is None. + :paramtype keyword: str + :keyword page: The page of the server configuration. Default value is None. + :paramtype page: int + :keyword page_size: The pageSize of the server configuration. Default value is None. + :paramtype page_size: int + :return: An iterator like instance of Configuration + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Configuration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_configurations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + tags=tags, + keyword=keyword, + page=page, + page_size=page_size, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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.Configuration], 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 _batch_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, 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_configurations_batch_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ConfigurationListForBatchUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: 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 ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Is one of the + following types: ConfigurationListForBatchUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or + JSON or IO[bytes] + :return: An instance of LROPoller that returns ConfigurationListResult. The + ConfigurationListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :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.ConfigurationListResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._batch_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.ConfigurationListResult, 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.ConfigurationListResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ConfigurationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Database: + """Gets information about 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: Database. The Database is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + 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) + + _stream = True + pipeline_response: PipelineResponse = 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 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 required parameters for creating or updating a database. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a database. Is one of the + following types: Database, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 _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) + + _stream = True + pipeline_response: PipelineResponse = self._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 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 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 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 + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.Database"]: + """List all the databases in 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 + :return: An iterator like instance of Database + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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 information about a server 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 server firewall rule. Required. + :type firewall_rule_name: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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) + + _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() + else: + deserialized = _deserialize(_models.FirewallRule, 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, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, 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_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) + + _stream = True + pipeline_response: PipelineResponse = 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 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, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_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 + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or JSON or IO[bytes] + :return: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :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.FirewallRule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + firewall_rule_name=firewall_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.FirewallRule, 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.FirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, firewall_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_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 = True + pipeline_response: PipelineResponse = self._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 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, firewall_rule_name: str, **kwargs: Any + ) -> LROPoller[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 server firewall rule. Required. + :type firewall_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, + firewall_rule_name=firewall_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.FirewallRule"]: + """List all the firewall rules in 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 + :return: An iterator like instance of FirewallRule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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) + + +class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.AdvancedThreatProtection: + """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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :return: AdvancedThreatProtection. The AdvancedThreatProtection is compatible with + MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_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) + + _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() + else: + deserialized = _deserialize(_models.AdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, 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_advanced_threat_protection_settings_update_put_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) + + _stream = True + pipeline_response: PipelineResponse = 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 cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + 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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: 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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + 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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is one of the + following types: AdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or JSON or + IO[bytes] + :return: An instance of LROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :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.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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_put_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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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_advanced_threat_protection_settings_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) + + _stream = True + pipeline_response: PipelineResponse = self._client._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 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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtectionForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: 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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is one of the + following types: AdvancedThreatProtectionForUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or + JSON or IO[bytes] + :return: An instance of LROPoller that returns AdvancedThreatProtection. The + AdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :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.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + 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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.AdvancedThreatProtection"]: + """Gets a list of 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 AdvancedThreatProtection + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_advanced_threat_protection_settings_list_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.AdvancedThreatProtection], 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 LocationBasedCapabilitySetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`location_based_capability_set` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, capability_set_name: str, **kwargs: Any) -> _models.Capability: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :param capability_set_name: Name of capability set. Required. + :type capability_set_name: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Capability] = kwargs.pop("cls", None) + + _request = build_location_based_capability_set_get_request( + location_name=location_name, + capability_set_name=capability_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Capability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of Capability + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_location_based_capability_set_list_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.Capability], 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 MaintenancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`maintenances` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def read( + self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any + ) -> _models.Maintenance: + """Read maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :return: Maintenance. The Maintenance is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + + _request = build_maintenances_read_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.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 = 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() + else: + deserialized = _deserialize(_models.Maintenance, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_maintenances_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_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 = True + pipeline_response: PipelineResponse = self._client._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 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, + maintenance_name: str, + parameters: Optional[_models.MaintenanceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Maintenance. The Maintenance is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: 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 Maintenance. The Maintenance is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: IO[bytes] + :keyword content_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 Maintenance. The Maintenance is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Is one of the + following types: MaintenanceUpdate, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Maintenance. The Maintenance is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :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)) + content_type = content_type if parameters else None + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + maintenance_name=maintenance_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.Maintenance, 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.Maintenance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Maintenance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Maintenance"]: + """List maintenances. + + :param resource_group_name: The name of the resource group. 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 Maintenance + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Maintenance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_maintenances_list_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.Maintenance], 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.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.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) + + _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() + 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) + + _stream = True + pipeline_response: PipelineResponse = 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["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 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create 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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create 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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Is one of the following types: + PrivateEndpointConnection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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) + + _stream = True + pipeline_response: PipelineResponse = self._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 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 associated + with the Azure resource. 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 + ) -> _models.PrivateEndpointConnectionListResult: + """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: PrivateEndpointConnectionListResult. The PrivateEndpointConnectionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + _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) + + _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() + else: + deserialized = _deserialize(_models.PrivateEndpointConnectionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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 MySQL 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.mysqlflexibleservers.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) + + _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() + 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"]: + """Lists the private link resources for MySQL 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.mysqlflexibleservers.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 None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=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 LocationBasedCapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> ItemPaged["_models.CapabilityProperties"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of CapabilityProperties + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapabilityProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_location_based_capabilities_list_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.CapabilityProperties], 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 CheckVirtualNetworkSubnetUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + parameters: _models.VirtualNetworkSubnetUsageParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def execute( + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is one of the following types: + VirtualNetworkSubnetUsageParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or + JSON or IO[bytes] + :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~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.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_check_virtual_network_subnet_usage_execute_request( + location_name=location_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 = 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() + else: + deserialized = _deserialize(_models.VirtualNetworkSubnetUsageResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class CheckNameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, + location_name: str, + name_availability_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, + location_name: str, + name_availability_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def execute( + self, + location_name: str, + name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Is one of the following types: + NameAvailabilityRequest, JSON, IO[bytes] Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_check_name_availability_execute_request( + location_name=location_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 = 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() + else: + deserialized = _deserialize(_models.NameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`check_name_availability_without_location` attribute. + """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) @@ -75,19 +10782,429 @@ def __init__(self, *args, **kwargs) -> None: self._serialize: Serializer = input_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 execute( + self, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, name_availability_request: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: - """List the operations for the provider. + def execute( + self, name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Operation] + :param name_availability_request: The request body. Is one of the following types: + NameAvailabilityRequest, JSON, IO[bytes] Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] + :return: NameAvailability. The NameAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_check_name_availability_without_location_execute_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) + + _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() + else: + deserialized = _deserialize(_models.NameAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class OperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusExtendedResult. The OperationStatusExtendedResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) + + _request = build_operation_results_get_request( + 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) + + _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() + else: + deserialized = _deserialize(_models.OperationStatusExtendedResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class OperationProgressOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationProgressResult. The OperationProgressResult is compatible with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) + + _request = build_operation_progress_get_request( + 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) + + _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() + else: + deserialized = _deserialize(_models.OperationProgressResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class GetPrivateDnsZoneSuffixOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: + """Get private DNS zone suffix in the cloud. + + :return: GetPrivateDnsZoneSuffixResponse. The GetPrivateDnsZoneSuffixResponse is compatible + with MutableMapping + :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) + + _request = build_get_private_dns_zone_suffix_execute_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) + + _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() + else: + deserialized = _deserialize(_models.GetPrivateDnsZoneSuffixResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`replicas` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Server"]: + """List all the replicas 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 + :return: An iterator like instance of Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Server] :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", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -100,12 +11217,20 @@ 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_replicas_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, ) - _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: # make call to next link with the client's api-version @@ -120,16 +11245,21 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._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.Server], 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) @@ -142,9 +11272,9 @@ 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) - error = self._deserialize.failsafe_deserialize( + error = _failsafe_deserialize( _models.ErrorResponse, - pipeline_response, + response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index e67963de2973..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,697 +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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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 - ) -> _models.PrivateEndpointConnectionListResult: - """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: PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_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("PrivateEndpointConnectionListResult", 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, 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, 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", self._config.api_version)) - 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, 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 == 201: - 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.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, - 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create 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.mysqlflexibleservers.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. The 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Is either a PrivateEndpointConnection type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, 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.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", self._config.api_version)) - 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) - 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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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, 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 associated - with the Azure resource. 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", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_link_resources_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_link_resources_operations.py deleted file mode 100644 index b2ca46326221..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/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.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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateLinkResources", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateLinkResources/{groupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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 - ) -> _models.PrivateLinkResourceListResult: - """Lists the private link resources for MySQL 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: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - 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("PrivateLinkResourceListResult", 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, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets a private link resource for MySQL 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 or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py deleted file mode 100644 index 6f4151aee983..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py +++ /dev/null @@ -1,178 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/replicas", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Server"]: - """List all the replicas 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 - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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_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: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py deleted file mode 100644 index eb082441012c..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py +++ /dev/null @@ -1,216 +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 MySQLManagementClientConfiguration -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_cutover_migration_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/cutoverMigration", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 _cutover_migration_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", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_cutover_migration( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> LROPoller[_models.Server]: - """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible - 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 either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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._cutover_migration_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("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, 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.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 - ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py deleted file mode 100644 index ae592463d73b..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py +++ /dev/null @@ -1,2327 +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 -import urllib.parse - -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 MySQLManagementClientConfiguration -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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/flexibleServers") - 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", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/detachVNet", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/failover", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/resetGtid", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/restart", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/start", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/stop", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: - _headers = case_insensitive_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-12-30")) - 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.DBforMySQL/flexibleServers/{serverName}/validateEstimateHighAvailability", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Server"]: - """List all the servers in a given subscription. - - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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, **kwargs: Any) -> ItemPaged["_models.Server"]: - """List all the servers in a given 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 either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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, **kwargs: Any) -> _models.Server: - """Gets information about 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: Server or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) - 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, - 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_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", self._config.api_version)) - 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_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 == 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.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( - self, - resource_group_name: str, - server_name: str, - parameters: _models.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] - :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[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Is either a - Server type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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): - 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, 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.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.ServerForUpdate, 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", self._config.api_version)) - 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, "ServerForUpdate") - - _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")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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.ServerForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate - :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerForUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is either a ServerForUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, 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.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", self._config.api_version)) - 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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - 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. 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - 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, 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[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 _detach_v_net_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, 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", self._config.api_version)) - 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, "ServerDetachVNetParameter") - - _request = build_detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerDetachVNetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter - :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Is either a - ServerDetachVNetParameter type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._detach_v_net_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, 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.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 _failover_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", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_failover(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Manual failover 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._failover_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, 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 _reset_gtid_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, 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", self._config.api_version)) - 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, "ServerGtidSetParameter") - - _request = build_reset_gtid_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerGtidSetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter - :keyword content_type: Body Parameter 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: IO[bytes] - :keyword content_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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Is either a - ServerGtidSetParameter type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reset_gtid_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, 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[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 _restart_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, 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", self._config.api_version)) - 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, "ServerRestartParameter") - - _request = build_restart_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerRestartParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter - :keyword content_type: Body Parameter 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: IO[bytes] - :keyword content_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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Restarts 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 required parameters for restarting a server. Is either a - ServerRestartParameter type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_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, 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 _start_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", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_start_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Starts 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_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, 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 _stop_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", self._config.api_version)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_stop_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - 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_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Stops 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 either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._stop_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, 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 - - @overload - def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: _models.HighAvailabilityValidationEstimation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.HighAvailabilityValidationEstimation, IO[bytes]], - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is - either a HighAvailabilityValidationEstimation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - or IO[bytes] - :return: HighAvailabilityValidationEstimation or the result of cls(response) - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~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", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "HighAvailabilityValidationEstimation") - - _request = build_validate_estimate_high_availability_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("HighAvailabilityValidationEstimation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py index a69fdaf79337..1d9bd29021b3 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AdvancedThreatProtectionSettingsGet.json +# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_list.py index 9355cb3f1b93..132bad404c39 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AdvancedThreatProtectionSettingsList.json +# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py index 66dd878eee54..6f7da739ddee 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AdvancedThreatProtectionSettingsPatchDisabled.json +# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPatchDisabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py index 29273a9b7b84..23f4ff18e734 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AdvancedThreatProtectionSettingsPatchEnabled.json +# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPatchEnabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py index 3162c616119f..50fc66f6f76d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.begin_update_put( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AdvancedThreatProtectionSettingsPutDisabled.json +# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPutDisabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py index cfde3dc7b68e..2ec6388d83bc 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.advanced_threat_protection_settings.begin_update_put( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AdvancedThreatProtectionSettingsPutEnabled.json +# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPutEnabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_create.py index 73b8467f9ba3..3195009dc94e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.azure_ad_administrators.begin_create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AzureADAdministratorCreate.json +# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_delete.py index 73b0d4ab220e..07c1ae1c1086 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.azure_ad_administrators.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AzureADAdministratorDelete.json +# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_get.py index c94a3e5d5870..5f4b3096bd88 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.azure_ad_administrators.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AzureADAdministratorGet.json +# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_list_by_server.py index ac4b3f6e9126..ba91d8b176c1 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.azure_ad_administrators.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/AzureADAdministratorsListByServer.json +# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_export.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_export.py index c4979ba8ac90..8bce0a56045c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_export.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backup_and_export.begin_create( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/BackupAndExport.json +# x-ms-original-file: 2025-06-01-preview/BackupAndExport.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_get.py index c7280b9cf127..0ee990f18523 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/BackupGet.json +# x-ms-original-file: 2025-06-01-preview/BackupGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_put.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_put.py index 57411c5508d8..faf010f96a09 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_put.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups.put( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/BackupPut.json +# x-ms-original-file: 2025-06-01-preview/BackupPut.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_list_by_server.py index 00877bf3b663..a944b8df2458 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backups.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/BackupsListByServer.json +# x-ms-original-file: 2025-06-01-preview/BackupsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_list.py index 61a5a1086aad..08cea91cb823 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.location_based_capabilities.list( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/CapabilitiesByLocationList.json +# x-ms-original-file: 2025-06-01-preview/CapabilitiesByLocationList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_by_location.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_by_location.py index 3118aad6f226..d7f8ef6f6fd5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_by_location.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_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,15 +27,16 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.location_based_capability_set.get( location_name="WestUS", + capability_set_name="default", ) print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/CapabilitySetByLocation.json +# x-ms-original-file: 2025-06-01-preview/CapabilitySetByLocation.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_list_by_location.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_list_by_location.py index c3bb147526a6..5266e933cb6f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_list_by_location.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.location_based_capability_set.list( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/CapabilitySetListByLocation.json +# x-ms-original-file: 2025-06-01-preview/CapabilitySetListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py index 33a69bda6639..8237ffa57960 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.check_name_availability.execute( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/CheckNameAvailability.json +# x-ms-original-file: 2025-06-01-preview/CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_location.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_location.py index 8dfb099f5400..583aa94afb7f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_location.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.check_name_availability_without_location.execute( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/CheckNameAvailabilityWithoutLocation.json +# x-ms-original-file: 2025-06-01-preview/CheckNameAvailabilityWithoutLocation.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.py index 70cfe6002714..5bfc05420044 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.check_virtual_network_subnet_usage.execute( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/CheckVirtualNetworkSubnetUsage.json +# x-ms-original-file: 2025-06-01-preview/CheckVirtualNetworkSubnetUsage.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_create_or_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_create_or_update.py index 3fa3f616091d..805834b5fc50 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_create_or_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ConfigurationCreateOrUpdate.json +# x-ms-original-file: 2025-06-01-preview/ConfigurationCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_get.py index d571c6aba42b..7e00bfd4a722 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ConfigurationGet.json +# x-ms-original-file: 2025-06-01-preview/ConfigurationGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_update.py index 5d432730e97d..5a2353c6d53b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ConfigurationUpdate.json +# x-ms-original-file: 2025-06-01-preview/ConfigurationUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_update.py index d1fd31b6667e..dfce75834fd5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.begin_batch_update( @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ConfigurationsBatchUpdate.json +# x-ms-original-file: 2025-06-01-preview/ConfigurationsBatchUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_list_by_server.py index d1b80f2ab2b6..a43f7bc5cbd3 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/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. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.configurations.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ConfigurationsListByServer.json +# x-ms-original-file: 2025-06-01-preview/ConfigurationsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py index 210ab39f9660..b9933751fa5c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers_migration.begin_cutover_migration( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/CutoverMigration.json +# x-ms-original-file: 2025-06-01-preview/CutoverMigration.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_create.py index 9e49b396548a..1111ead8869a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/DatabaseCreate.json +# x-ms-original-file: 2025-06-01-preview/DatabaseCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_delete.py index 4bfdf744cace..2f7edda1cdfd 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.databases.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/DatabaseDelete.json +# x-ms-original-file: 2025-06-01-preview/DatabaseDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_get.py index 569516e84c98..ce5771db35bf 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/DatabaseGet.json +# x-ms-original-file: 2025-06-01-preview/DatabaseGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_list_by_server.py index 8d8f267eef98..0b2b53fe1f64 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/DatabasesListByServer.json +# x-ms-original-file: 2025-06-01-preview/DatabasesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_create.py index 485afc22c0bc..be7bad88281c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/FirewallRuleCreate.json +# x-ms-original-file: 2025-06-01-preview/FirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_delete.py index 5e7f647aa6b9..c2614aed4dab 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.firewall_rules.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/FirewallRuleDelete.json +# x-ms-original-file: 2025-06-01-preview/FirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_get.py index 2a8f0502b772..5dd066a62324 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/FirewallRuleGet.json +# x-ms-original-file: 2025-06-01-preview/FirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_list_by_server.py index 09ff5cc27de9..2b996ab77b78 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/FirewallRulesListByServer.json +# x-ms-original-file: 2025-06-01-preview/FirewallRulesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py index 7aacf248122a..c26b8878ac62 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -35,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/GetPrivateDnsZoneSuffix.json +# x-ms-original-file: 2025-06-01-preview/GetPrivateDnsZoneSuffix.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_list_by_server.py index 9fa909484857..d93db436e54a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.log_files.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/LogFilesListByServer.json +# x-ms-original-file: 2025-06-01-preview/LogFilesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup.py index c492b1d526b7..86dd799dca33 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_running_backup.begin_create( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/LongRunningBackup.json +# x-ms-original-file: 2025-06-01-preview/LongRunningBackup.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.py new file mode 100644 index 000000000000..8b4ffc231e8d --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.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.mysqlflexibleservers import MySQLManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mysqlflexibleservers +# USAGE + python long_running_backup_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 = MySQLManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.long_running_backup.begin_delete( + resource_group_name="TestGroup", + server_name="mysqltestserver", + backup_name="testback", + ).result() + + +# x-ms-original-file: 2025-06-01-preview/LongRunningBackupDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_get.py index 5888ab9dd112..d86b074713d7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_running_backups.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/LongRunningBackupGet.json +# x-ms-original-file: 2025-06-01-preview/LongRunningBackupGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_list_by_server.py index d9525dea366c..e436eb8f48f5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_running_backups.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/LongRunningBackupsListByServer.json +# x-ms-original-file: 2025-06-01-preview/LongRunningBackupsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py index 674af735f9e1..bf0f090e454b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/MaintenancePolicyPatchOptInVirtualCanary.json +# x-ms-original-file: 2025-06-01-preview/MaintenancePolicyPatchOptInVirtualCanary.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py index 26d95bef732f..938a96e17713 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/MaintenancePolicyPatchOptOutVirtualCanary.json +# x-ms-original-file: 2025-06-01-preview/MaintenancePolicyPatchOptOutVirtualCanary.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py index e50eb3277eb7..1d64ab8cc4f0 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.maintenances.read( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/MaintenanceRead.json +# x-ms-original-file: 2025-06-01-preview/MaintenanceRead.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_update.py index 39d72d231318..685a7287dfc7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.maintenances.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/MaintenanceUpdate.json +# x-ms-original-file: 2025-06-01-preview/MaintenanceUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_list_by_server.py index 4fbafccab68d..1b774360d783 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.maintenances.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/MaintenancesListByServer.json +# x-ms-original-file: 2025-06-01-preview/MaintenancesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_export.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_export.py index ff5277e42aa6..0c29d1674198 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_export.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.operation_progress.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/OperationProgress_Get_BackupAndExport.json +# x-ms-original-file: 2025-06-01-preview/OperationProgress_Get_BackupAndExport.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py index 2c2c410e5b7a..6fb637b5a988 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.operation_progress.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/OperationProgress_Get_ImportFromStorage.json +# x-ms-original-file: 2025-06-01-preview/OperationProgress_Get_ImportFromStorage.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_get.py index 7559a9c35942..d442089123d2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.operation_results.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/OperationResults_Get.json +# x-ms-original-file: 2025-06-01-preview/OperationResults_Get.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_list.py index 19c2e66ec79b..7873a0c29667 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_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. # -------------------------------------------------------------------------- @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/OperationsList.json +# x-ms-original-file: 2025-06-01-preview/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_delete.py index 7edd2d7206d6..b2f946a764dc 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( 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/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/PrivateEndpointConnectionDelete.json +# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_get.py index 588b3b7965e0..b66e2eb7fa2f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( 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/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/PrivateEndpointConnectionGet.json +# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_list.py index e54644937afb..886f7f9632d2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.list_by_server( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/PrivateEndpointConnectionList.json +# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_update.py index 7448bd0192e4..46ddfb75760e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( 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/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/PrivateEndpointConnectionUpdate.json +# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_get.py index 8a139e7f96c2..335c2541b2f0 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( 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/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/PrivateLinkResourcesGet.json +# x-ms-original-file: 2025-06-01-preview/PrivateLinkResourcesGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_list.py index 528ef7555f84..02cda7c8a770 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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,16 +27,17 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_link_resources.list_by_server( resource_group_name="Default", server_name="test-svr", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/PrivateLinkResourcesList.json +# x-ms-original-file: 2025-06-01-preview/PrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_list_by_server.py index 33b492796284..13adf769a267 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.replicas.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ReplicasListByServer.json +# x-ms-original-file: 2025-06-01-preview/ReplicasListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create.py index 125d5779aa5c..acbab5d6995d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create( @@ -58,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreate.json +# x-ms-original-file: 2025-06-01-preview/ServerCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_replica.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_replica.py index 8e54d3b3b75b..992dd1066cc4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_replica.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateReplica.json +# x-ms-original-file: 2025-06-01-preview/ServerCreateReplica.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.py index 1a81d48378ec..d9a76b7bbba5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create( @@ -71,6 +71,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateWithBYOK.json +# x-ms-original-file: 2025-06-01-preview/ServerCreateWithBYOK.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py index 906e704515e8..effed8aaf406 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create( @@ -59,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateWithDatabasePort.json +# x-ms-original-file: 2025-06-01-preview/ServerCreateWithDatabasePort.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.py new file mode 100644 index 000000000000..890b97b583bf --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.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.mysqlflexibleservers import MySQLManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mysqlflexibleservers +# USAGE + python server_create_with_lower_case_table_names.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 = MySQLManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.servers.begin_create( + resource_group_name="testrg", + server_name="mysqltestserver", + parameters={ + "location": "southeastasia", + "properties": { + "administratorLogin": "cloudsa", + "administratorLoginPassword": "your_password", + "availabilityZone": "1", + "backup": {"backupIntervalHours": 24, "backupRetentionDays": 7, "geoRedundantBackup": "Disabled"}, + "createMode": "Default", + "databasePort": 8888, + "highAvailability": { + "mode": "ZoneRedundant", + "replicationMode": "BinaryLog", + "standbyAvailabilityZone": "3", + }, + "lowerCaseTableNames": 1, + "storage": { + "autoGrow": "Disabled", + "iops": 600, + "storageRedundancy": "LocalRedundancy", + "storageSizeGB": 100, + }, + "version": "8.0.21", + }, + "sku": {"name": "Standard_D2ds_v4", "tier": "GeneralPurpose"}, + "tags": {"num": "1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-06-01-preview/ServerCreateWithLowerCaseTableNames.json +if __name__ == "__main__": + main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_point_in_time_restore.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_point_in_time_restore.py index 2d92459d263a..ff3ab7e93660 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_point_in_time_restore.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerCreateWithPointInTimeRestore.json +# x-ms-original-file: 2025-06-01-preview/ServerCreateWithPointInTimeRestore.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_delete.py index c0f417a99d46..403a075a8d11 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerDelete.json +# x-ms-original-file: 2025-06-01-preview/ServerDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py index 043dbba78952..7def78ea2ef0 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_detach_v_net( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerDetachVNet.json +# x-ms-original-file: 2025-06-01-preview/ServerDetachVNet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_failover.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_failover.py index ce0cabcebe4b..0db72c5bc4e4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_failover.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_failover( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerFailover.json +# x-ms-original-file: 2025-06-01-preview/ServerFailover.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get.py index 627a08b1bc6a..bb95445207ea 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerGet.json +# x-ms-original-file: 2025-06-01-preview/ServerGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py index 98ebb6eff0e7..262896a308da 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerGetWithVnet.json +# x-ms-original-file: 2025-06-01-preview/ServerGetWithVnet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py index 56c4e821f101..4a0212c54946 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_reset_gtid( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerResetGtid.json +# x-ms-original-file: 2025-06-01-preview/ServerResetGtid.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py index ae8b89b751c0..4780ceb74b86 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_restart( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerRestart.json +# x-ms-original-file: 2025-06-01-preview/ServerRestart.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py index 735b0f00c987..27fcd576006e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_start( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerStart.json +# x-ms-original-file: 2025-06-01-preview/ServerStart.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py index 9cfc88c8e70a..e637f8ae48e7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_stop( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerStop.json +# x-ms-original-file: 2025-06-01-preview/ServerStop.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update.py index 831167a3f4e9..0f61f5b905e4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerUpdate.json +# x-ms-original-file: 2025-06-01-preview/ServerUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.py index ea81e712bfa1..0610a61d0ca7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerUpdateWithBYOK.json +# x-ms-original-file: 2025-06-01-preview/ServerUpdateWithBYOK.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py index a0523ee4aff3..15f2497d071b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerUpdateWithCustomerMaintenanceWindow.json +# x-ms-original-file: 2025-06-01-preview/ServerUpdateWithCustomerMaintenanceWindow.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py index c390a200c615..f9445644acef 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.validate_estimate_high_availability( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServerValidateEstimateHighAvailability.json +# x-ms-original-file: 2025-06-01-preview/ServerValidateEstimateHighAvailability.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list.py index 0210c352d108..e18d70be226b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServersList.json +# x-ms-original-file: 2025-06-01-preview/ServersList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list_by_resource_group.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list_by_resource_group.py index af888e092e08..2d50043ced8c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list_by_resource_group.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ServersListByResourceGroup.json +# x-ms-original-file: 2025-06-01-preview/ServersListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_backup.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_backup.py index 5cd3078b3410..8360337e06df 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_backup.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_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 = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + subscription_id="SUBSCRIPTION_ID", ) response = client.backup_and_export.validate_backup( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2024-12-30/examples/ValidateBackup.json +# x-ms-original-file: 2025-06-01-preview/ValidateBackup.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/conftest.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/conftest.py index 1ba62909429d..84ee2c1dc115 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/conftest.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations.py index 981761a23d9c..88eef5b97021 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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 TestMySQLManagementAdvancedThreatProtectionSettingsOperations(AzureMgmtRec def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_advanced_threat_protection_settings_list(self, resource_group): - response = self.client.advanced_threat_protection_settings.list( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_advanced_threat_protection_settings_get(self, resource_group): @@ -37,7 +25,6 @@ def test_advanced_threat_protection_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -51,11 +38,9 @@ def test_advanced_threat_protection_settings_begin_update_put(self, resource_gro server_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "provisioningState": "str", - "state": "str", + "properties": {"creationTime": "2020-02-20 00:00:00", "provisioningState": "str", "state": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -66,7 +51,6 @@ def test_advanced_threat_protection_settings_begin_update_put(self, resource_gro }, "type": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -79,9 +63,19 @@ def test_advanced_threat_protection_settings_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - parameters={"state": "str"}, - api_version="2024-12-30", + parameters={"properties": {"state": "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_advanced_threat_protection_settings_list(self, resource_group): + response = self.client.advanced_threat_protection_settings.list( + 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations_async.py index 6a1661501954..89027672c837 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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 TestMySQLManagementAdvancedThreatProtectionSettingsOperationsAsync(AzureMg def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_advanced_threat_protection_settings_list(self, resource_group): - response = self.client.advanced_threat_protection_settings.list( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - 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_advanced_threat_protection_settings_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_advanced_threat_protection_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -53,11 +40,9 @@ async def test_advanced_threat_protection_settings_begin_update_put(self, resour server_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "provisioningState": "str", - "state": "str", + "properties": {"creationTime": "2020-02-20 00:00:00", "provisioningState": "str", "state": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -68,7 +53,6 @@ async def test_advanced_threat_protection_settings_begin_update_put(self, resour }, "type": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -83,10 +67,20 @@ async def test_advanced_threat_protection_settings_begin_update(self, resource_g resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - parameters={"state": "str"}, - api_version="2024-12-30", + parameters={"properties": {"state": "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_advanced_threat_protection_settings_list(self, resource_group): + response = self.client.advanced_threat_protection_settings.list( + 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations.py index 9c01f0780529..a72be9b0cde9 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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 @@ -18,18 +18,6 @@ class TestMySQLManagementAzureADAdministratorsOperations(AzureMgmtRecordedTestCa def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_azure_ad_administrators_list_by_server(self, resource_group): - response = self.client.azure_ad_administrators.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_azure_ad_administrators_get(self, resource_group): @@ -37,7 +25,6 @@ def test_azure_ad_administrators_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -51,12 +38,15 @@ def test_azure_ad_administrators_begin_create_or_update(self, resource_group): server_name="str", administrator_name="str", parameters={ - "administratorType": "str", "id": "str", - "identityResourceId": "str", - "login": "str", "name": "str", - "sid": "str", + "properties": { + "administratorType": "str", + "identityResourceId": "str", + "login": "str", + "sid": "str", + "tenantId": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -65,10 +55,8 @@ def test_azure_ad_administrators_begin_create_or_update(self, resource_group): "lastModifiedBy": "str", "lastModifiedByType": "str", }, - "tenantId": "str", "type": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -81,8 +69,18 @@ def test_azure_ad_administrators_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2024-12-30", ).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_azure_ad_administrators_list_by_server(self, resource_group): + response = self.client.azure_ad_administrators.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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations_async.py index 78a754e58e37..e8435bfd2aea 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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 @@ -19,18 +19,6 @@ class TestMySQLManagementAzureADAdministratorsOperationsAsync(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_azure_ad_administrators_list_by_server(self, resource_group): - response = self.client.azure_ad_administrators.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - 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_azure_ad_administrators_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_azure_ad_administrators_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -53,12 +40,15 @@ async def test_azure_ad_administrators_begin_create_or_update(self, resource_gro server_name="str", administrator_name="str", parameters={ - "administratorType": "str", "id": "str", - "identityResourceId": "str", - "login": "str", "name": "str", - "sid": "str", + "properties": { + "administratorType": "str", + "identityResourceId": "str", + "login": "str", + "sid": "str", + "tenantId": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -67,10 +57,8 @@ async def test_azure_ad_administrators_begin_create_or_update(self, resource_gro "lastModifiedBy": "str", "lastModifiedByType": "str", }, - "tenantId": "str", "type": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -85,9 +73,19 @@ async def test_azure_ad_administrators_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2024-12-30", ) ).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_azure_ad_administrators_list_by_server(self, resource_group): + response = self.client.azure_ad_administrators.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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations.py index 2addc853f7f3..e793c89f845e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_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_backup_and_export_begin_create(self, resource_group): "backupSettings": {"backupName": "str", "backupFormat": "str"}, "targetDetails": "backup_store_details", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -40,7 +39,6 @@ def test_backup_and_export_validate_backup(self, resource_group): response = self.client.backup_and_export.validate_backup( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations_async.py index 88e93b10a516..1ab985e2ba50 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_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_backup_and_export_begin_create(self, resource_group): "backupSettings": {"backupName": "str", "backupFormat": "str"}, "targetDetails": "backup_store_details", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -43,7 +42,6 @@ async def test_backup_and_export_validate_backup(self, resource_group): response = await self.client.backup_and_export.validate_backup( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations.py index 60771e42104f..efae36c30df4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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,24 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_backups_list_by_server(self, resource_group): - response = self.client.backups.list_by_server( + def test_backups_get(self, resource_group): + response = self.client.backups.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", + 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_backups_get(self, resource_group): - response = self.client.backups.get( + def test_backups_put(self, resource_group): + response = self.client.backups.put( resource_group_name=resource_group.name, server_name="str", backup_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -45,13 +44,11 @@ def test_backups_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_backups_put(self, resource_group): - response = self.client.backups.put( + def test_backups_list_by_server(self, resource_group): + response = self.client.backups.list_by_server( resource_group_name=resource_group.name, server_name="str", - backup_name="str", - api_version="2024-12-30", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations_async.py index e19e006308a3..d5bce47fa14a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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,24 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_backups_list_by_server(self, resource_group): - response = self.client.backups.list_by_server( + async def test_backups_get(self, resource_group): + response = await self.client.backups.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", + backup_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_backups_get(self, resource_group): - response = await self.client.backups.get( + async def test_backups_put(self, resource_group): + response = await self.client.backups.put( resource_group_name=resource_group.name, server_name="str", backup_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -46,13 +45,11 @@ async def test_backups_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_backups_put(self, resource_group): - response = await self.client.backups.put( + async def test_backups_list_by_server(self, resource_group): + response = self.client.backups.list_by_server( resource_group_name=resource_group.name, server_name="str", - backup_name="str", - api_version="2024-12-30", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations.py index 0632ed2387dc..5a4b2186dbed 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_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_check_name_availability_execute(self, resource_group): response = self.client.check_name_availability.execute( location_name="str", name_availability_request={"name": "str", "type": "str"}, - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations_async.py index 37a2e31e53cf..58fe32117213 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_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_check_name_availability_execute(self, resource_group): response = await self.client.check_name_availability.execute( location_name="str", name_availability_request={"name": "str", "type": "str"}, - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations.py index 30293acf47ca..d46d6ed395e5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_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_check_name_availability_without_location_execute(self, resource_group): response = self.client.check_name_availability_without_location.execute( name_availability_request={"name": "str", "type": "str"}, - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations_async.py index b48de9559710..f2e18a477ead 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_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_check_name_availability_without_location_execute(self, resource_group): response = await self.client.check_name_availability_without_location.execute( name_availability_request={"name": "str", "type": "str"}, - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations.py index 2d3102ed7d95..edcb6c0b4844 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_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_check_virtual_network_subnet_usage_execute(self, resource_group): response = self.client.check_virtual_network_subnet_usage.execute( location_name="str", parameters={"virtualNetworkResourceId": "str"}, - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations_async.py index 83213542d46e..517ed2192b59 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_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_check_virtual_network_subnet_usage_execute(self, resource_group): response = await self.client.check_virtual_network_subnet_usage.execute( location_name="str", parameters={"virtualNetworkResourceId": "str"}, - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations.py index 77683dd8f793..9db3879d456f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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 @@ -18,18 +18,6 @@ class TestMySQLManagementConfigurationsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_configurations_list_by_server(self, resource_group): - response = self.client.configurations.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_configurations_get(self, resource_group): @@ -37,7 +25,6 @@ def test_configurations_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", configuration_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -51,18 +38,21 @@ def test_configurations_begin_create_or_update(self, resource_group): server_name="str", configuration_name="str", parameters={ - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", "id": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", "name": "str", - "source": "str", + "properties": { + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", + "source": "str", + "value": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -72,9 +62,7 @@ def test_configurations_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", - "value": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -88,18 +76,21 @@ def test_configurations_begin_update(self, resource_group): server_name="str", configuration_name="str", parameters={ - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", "id": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", "name": "str", - "source": "str", + "properties": { + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", + "source": "str", + "value": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -109,22 +100,33 @@ def test_configurations_begin_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", - "value": "str", }, - api_version="2024-12-30", ).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_configurations_list_by_server(self, resource_group): + response = self.client.configurations.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_configurations_begin_batch_update(self, resource_group): response = self.client.configurations.begin_batch_update( resource_group_name=resource_group.name, server_name="str", - parameters={"resetAllToDefault": "str", "value": [{"name": "str", "source": "str", "value": "str"}]}, - api_version="2024-12-30", + parameters={ + "resetAllToDefault": "str", + "value": [{"name": "str", "properties": {"source": "str", "value": "str"}}], + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations_async.py index 32279ccf8511..9bfc9d68a778 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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 @@ -19,18 +19,6 @@ class TestMySQLManagementConfigurationsOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_configurations_list_by_server(self, resource_group): - response = self.client.configurations.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - 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_configurations_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_configurations_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", configuration_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -53,18 +40,21 @@ async def test_configurations_begin_create_or_update(self, resource_group): server_name="str", configuration_name="str", parameters={ - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", "id": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", "name": "str", - "source": "str", + "properties": { + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", + "source": "str", + "value": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -74,9 +64,7 @@ async def test_configurations_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", - "value": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -92,18 +80,21 @@ async def test_configurations_begin_update(self, resource_group): server_name="str", configuration_name="str", parameters={ - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", "id": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", "name": "str", - "source": "str", + "properties": { + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", + "source": "str", + "value": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -113,15 +104,24 @@ async def test_configurations_begin_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", - "value": "str", }, - api_version="2024-12-30", ) ).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_configurations_list_by_server(self, resource_group): + response = self.client.configurations.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_configurations_begin_batch_update(self, resource_group): @@ -129,8 +129,10 @@ async def test_configurations_begin_batch_update(self, resource_group): await self.client.configurations.begin_batch_update( resource_group_name=resource_group.name, server_name="str", - parameters={"resetAllToDefault": "str", "value": [{"name": "str", "source": "str", "value": "str"}]}, - api_version="2024-12-30", + parameters={ + "resetAllToDefault": "str", + "value": [{"name": "str", "properties": {"source": "str", "value": "str"}}], + }, ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations.py index da75e42a683d..8579f0368e85 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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,18 +18,6 @@ class TestMySQLManagementDatabasesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @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="2024-12-30", - ) - 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): @@ -37,7 +25,6 @@ def test_databases_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -51,10 +38,9 @@ def test_databases_begin_create_or_update(self, resource_group): server_name="str", database_name="str", parameters={ - "charset": "str", - "collation": "str", "id": "str", "name": "str", + "properties": {"charset": "str", "collation": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -65,7 +51,6 @@ def test_databases_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -78,8 +63,18 @@ def test_databases_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2024-12-30", ).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 + # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations_async.py index c303bd91080e..e65a91e12a54 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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,18 +19,6 @@ class TestMySQLManagementDatabasesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @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="2024-12-30", - ) - 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): @@ -38,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="2024-12-30", ) # please add some check logic here by yourself @@ -53,10 +40,9 @@ async def test_databases_begin_create_or_update(self, resource_group): server_name="str", database_name="str", parameters={ - "charset": "str", - "collation": "str", "id": "str", "name": "str", + "properties": {"charset": "str", "collation": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -67,7 +53,6 @@ async def test_databases_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -82,9 +67,19 @@ async def test_databases_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2024-12-30", ) ).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 + # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations.py index 226ede3a0eb9..260d5b11c7ed 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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 @@ -18,18 +18,6 @@ class TestMySQLManagementFirewallRulesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - 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="2024-12-30", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_firewall_rules_get(self, resource_group): @@ -37,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="2024-12-30", ) # please add some check logic here by yourself @@ -51,8 +38,7 @@ def test_firewall_rules_begin_create_or_update(self, resource_group): server_name="str", firewall_rule_name="str", parameters={ - "endIpAddress": "str", - "startIpAddress": "str", + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, "id": "str", "name": "str", "systemData": { @@ -65,7 +51,6 @@ def test_firewall_rules_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -78,8 +63,18 @@ def test_firewall_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2024-12-30", ).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_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", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations_async.py index 646cce1b1ecd..8526e1cadb1c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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 @@ -19,18 +19,6 @@ class TestMySQLManagementFirewallRulesOperationsAsync(AzureMgmtRecordedTestCase) def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - 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="2024-12-30", - ) - 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_firewall_rules_get(self, resource_group): @@ -38,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="2024-12-30", ) # please add some check logic here by yourself @@ -53,8 +40,7 @@ async def test_firewall_rules_begin_create_or_update(self, resource_group): server_name="str", firewall_rule_name="str", parameters={ - "endIpAddress": "str", - "startIpAddress": "str", + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, "id": "str", "name": "str", "systemData": { @@ -67,7 +53,6 @@ async def test_firewall_rules_begin_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -82,9 +67,19 @@ async def test_firewall_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2024-12-30", ) ).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_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", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations.py index 87c0d5f2fec9..22b5185e2652 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_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_get_private_dns_zone_suffix_execute(self, resource_group): - response = self.client.get_private_dns_zone_suffix.execute( - api_version="2024-12-30", - ) + response = self.client.get_private_dns_zone_suffix.execute() # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations_async.py index cf81daf57182..163587a60fcf 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_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_get_private_dns_zone_suffix_execute(self, resource_group): - response = await self.client.get_private_dns_zone_suffix.execute( - api_version="2024-12-30", - ) + response = await self.client.get_private_dns_zone_suffix.execute() # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations.py index abfd726e244e..268374d3acbf 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_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_location_based_capabilities_list(self, resource_group): response = self.client.location_based_capabilities.list( location_name="str", - api_version="2024-12-30", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations_async.py index 0ee10a6af075..f970296254d8 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_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_location_based_capabilities_list(self, resource_group): response = self.client.location_based_capabilities.list( location_name="str", - api_version="2024-12-30", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations.py index 7fb834d064cf..aca80d00b6bf 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_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_location_based_capability_set_list(self, resource_group): - response = self.client.location_based_capability_set.list( + def test_location_based_capability_set_get(self, resource_group): + response = self.client.location_based_capability_set.get( location_name="str", - api_version="2024-12-30", + capability_set_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_location_based_capability_set_get(self, resource_group): - response = self.client.location_based_capability_set.get( + def test_location_based_capability_set_list(self, resource_group): + response = self.client.location_based_capability_set.list( location_name="str", - capability_set_name="default", - api_version="2024-12-30", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations_async.py index 16572bb8d34e..2a8e756f932a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_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_location_based_capability_set_list(self, resource_group): - response = self.client.location_based_capability_set.list( + async def test_location_based_capability_set_get(self, resource_group): + response = await self.client.location_based_capability_set.get( location_name="str", - api_version="2024-12-30", + capability_set_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_location_based_capability_set_get(self, resource_group): - response = await self.client.location_based_capability_set.get( + async def test_location_based_capability_set_list(self, resource_group): + response = self.client.location_based_capability_set.list( location_name="str", - capability_set_name="default", - api_version="2024-12-30", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations.py index a51afbbf6439..05f553414101 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_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_log_files_list_by_server(self, resource_group): response = self.client.log_files.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations_async.py index d357cc11895f..1d567d247718 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_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_log_files_list_by_server(self, resource_group): response = self.client.log_files.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations.py index f585dbff49a5..5beec4ca0ab2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_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,18 @@ def test_long_running_backup_begin_create(self, resource_group): resource_group_name=resource_group.name, server_name="str", backup_name="str", - api_version="2024-12-30", + ).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_running_backup_begin_delete(self, resource_group): + response = self.client.long_running_backup.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations_async.py index 823ed80cf5b5..120fb854853b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_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,20 @@ async def test_long_running_backup_begin_create(self, resource_group): resource_group_name=resource_group.name, server_name="str", backup_name="str", - api_version="2024-12-30", + ) + ).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_running_backup_begin_delete(self, resource_group): + response = await ( + await self.client.long_running_backup.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + backup_name="str", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations.py index 1f27de486ab0..5d907902984f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_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,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_running_backups_list(self, resource_group): - response = self.client.long_running_backups.list( + def test_long_running_backups_get(self, resource_group): + response = self.client.long_running_backups.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", + 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_running_backups_get(self, resource_group): - response = self.client.long_running_backups.get( + def test_long_running_backups_list(self, resource_group): + response = self.client.long_running_backups.list( resource_group_name=resource_group.name, server_name="str", - backup_name="str", - api_version="2024-12-30", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations_async.py index e4a575f51c49..f1a1a89ebf0e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_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,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_running_backups_list(self, resource_group): - response = self.client.long_running_backups.list( + async def test_long_running_backups_get(self, resource_group): + response = await self.client.long_running_backups.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", + backup_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_running_backups_get(self, resource_group): - response = await self.client.long_running_backups.get( + async def test_long_running_backups_list(self, resource_group): + response = self.client.long_running_backups.list( resource_group_name=resource_group.name, server_name="str", - backup_name="str", - api_version="2024-12-30", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations.py index 1889340e7ce7..625b58d590cc 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_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 TestMySQLManagementMaintenancesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_maintenances_list(self, resource_group): - response = self.client.maintenances.list( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_maintenances_read(self, resource_group): @@ -37,7 +25,6 @@ def test_maintenances_read(self, resource_group): resource_group_name=resource_group.name, server_name="str", maintenance_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -50,8 +37,18 @@ def test_maintenances_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", maintenance_name="str", - api_version="2024-12-30", ).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_maintenances_list(self, resource_group): + response = self.client.maintenances.list( + 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations_async.py index 132c7f78f093..9493c6c632f6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_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 TestMySQLManagementMaintenancesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_maintenances_list(self, resource_group): - response = self.client.maintenances.list( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - 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_maintenances_read(self, resource_group): @@ -38,7 +26,6 @@ async def test_maintenances_read(self, resource_group): resource_group_name=resource_group.name, server_name="str", maintenance_name="str", - api_version="2024-12-30", ) # please add some check logic here by yourself @@ -52,9 +39,19 @@ async def test_maintenances_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", maintenance_name="str", - api_version="2024-12-30", ) ).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_maintenances_list(self, resource_group): + response = self.client.maintenances.list( + 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations.py index 1a42fc6424e5..e1f09642b319 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_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_operation_progress_get(self, resource_group): response = self.client.operation_progress.get( location_name="str", operation_id="str", - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations_async.py index 213468d74eb0..8aee6cac528a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_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_operation_progress_get(self, resource_group): response = await self.client.operation_progress.get( location_name="str", operation_id="str", - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations.py index 9853de113d79..ce04999ebb24 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_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_operation_results_get(self, resource_group): response = self.client.operation_results.get( location_name="str", operation_id="str", - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations_async.py index 72ea4f4071a8..6c773713b589 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_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_operation_results_get(self, resource_group): response = await self.client.operation_results.get( location_name="str", operation_id="str", - api_version="2024-12-30", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations.py index 7ca8680726a4..911c55d1c42b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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="2024-12-30", - ) + response = self.client.operations.list() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations_async.py index e1697af53d26..a4a698b7266b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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="2024-12-30", - ) + response = self.client.operations.list() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations.py index e5b60c262c34..136d676388e4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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 TestMySQLManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @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="2024-12-30", - ) - - # 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="2024-12-30", ) # please add some check logic here by yourself @@ -51,12 +38,18 @@ 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": {"actionsRequired": "str", "description": "str", "status": "str"}, - "provisioningState": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -67,7 +60,6 @@ def test_private_endpoint_connections_begin_create_or_update(self, resource_grou }, "type": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -80,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="2024-12-30", ).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", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations_async.py index c725d1f469e7..5906dc72fff8 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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 TestMySQLManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtReco def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_private_endpoint_connections_list_by_server(self, resource_group): - response = await self.client.private_endpoint_connections.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-12-30", - ) - - # 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="2024-12-30", ) # please add some check logic here by yourself @@ -53,16 +40,18 @@ 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": { - "actionsRequired": "str", - "description": "str", - "status": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", }, - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -73,7 +62,6 @@ async def test_private_endpoint_connections_begin_create_or_update(self, resourc }, "type": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -88,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="2024-12-30", ) ).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 = await self.client.private_endpoint_connections.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations.py index 8be2804a4b98..5cc49761342a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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,11 +20,11 @@ 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="2024-12-30", + group_name="str", ) # please add some check logic here by yourself @@ -32,13 +32,11 @@ def test_private_link_resources_list_by_server(self, resource_group): @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="2024-12-30", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations_async.py index 798ffb4d74db..6128e2b874c0 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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,11 +21,11 @@ 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 = await 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="2024-12-30", + group_name="str", ) # please add some check logic here by yourself @@ -33,13 +33,11 @@ async def test_private_link_resources_list_by_server(self, resource_group): @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="2024-12-30", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations.py index 14848a2fdf23..e59a86991a2c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_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_replicas_list_by_server(self, resource_group): response = self.client.replicas.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations_async.py index 093369f85a5d..3cd89aca3d22 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_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_replicas_list_by_server(self, resource_group): response = self.client.replicas.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations.py index d199ce884b61..dfb4e09bef25 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_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_servers_migration_begin_cutover_migration(self, resource_group): response = self.client.servers_migration.begin_cutover_migration( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations_async.py index 67b64ef85f8b..b0a829f06af2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_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_servers_migration_begin_cutover_migration(self, resource_group): await self.client.servers_migration.begin_cutover_migration( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations.py index f149c33c388f..202a535c690b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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,34 +18,12 @@ class TestMySQLManagementServersOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_servers_list(self, resource_group): - response = self.client.servers.list( - api_version="2024-12-30", - ) - 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-12-30", - ) - 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-12-30", ) # please add some check logic here by yourself @@ -59,27 +37,6 @@ def test_servers_begin_create(self, resource_group): server_name="str", parameters={ "location": "str", - "administratorLogin": "str", - "administratorLoginPassword": "str", - "availabilityZone": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "createMode": "str", - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "databasePort": 0, - "fullVersion": "str", - "fullyQualifiedDomainName": "str", - "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, "id": "str", "identity": { "principalId": "str", @@ -87,64 +44,96 @@ def test_servers_begin_create(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "importSourceProperties": { - "dataDirPath": "str", - "sasToken": "str", - "storageType": "str", - "storageUrl": "str", - }, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, "name": "str", - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", - }, - "privateEndpointConnections": [ - { - "groupIds": ["str"], - "id": "str", - "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "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", - }, + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "availabilityZone": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "createMode": "str", + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", "type": "str", - } - ], - "replicaCapacity": 0, - "replicationRole": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sku": {"name": "str", "tier": "str"}, - "sourceServerResourceId": "str", - "state": "str", - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "LocalRedundancy", - "storageSizeGB": 0, - "storageSku": "str", + }, + "databasePort": 0, + "fullVersion": "str", + "fullyQualifiedDomainName": "str", + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, + "importSourceProperties": { + "dataDirPath": "str", + "sasToken": "str", + "storageType": "str", + "storageUrl": "str", + }, + "lowerCaseTableNames": 0, + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", + }, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "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", + } + ], + "replicaCapacity": 0, + "replicationRole": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sourceServerResourceId": "str", + "state": "str", + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "str", + "storageSizeGB": 0, + "storageSku": "str", + }, + "version": "str", }, + "sku": {"name": "str", "tier": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -155,9 +144,7 @@ def test_servers_begin_create(self, resource_group): }, "tags": {"str": "str"}, "type": "str", - "version": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -170,55 +157,61 @@ def test_servers_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "administratorLoginPassword": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", + "properties": { + "administratorLoginPassword": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", + }, + "replicationRole": "str", + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "str", + "storageSizeGB": 0, + "storageSku": "str", + }, + "version": "str", }, - "replicationRole": "str", "sku": {"name": "str", "tier": "str"}, - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "LocalRedundancy", - "storageSizeGB": 0, - "storageSku": "str", - }, "tags": {"str": "str"}, - "version": "str", }, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -230,7 +223,6 @@ 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-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -238,14 +230,19 @@ def test_servers_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_servers_begin_detach_v_net(self, resource_group): - response = self.client.servers.begin_detach_v_net( + def test_servers_list_by_resource_group(self, resource_group): + response = self.client.servers.list_by_resource_group( resource_group_name=resource_group.name, - server_name="str", - parameters={"publicNetworkAccess": "str"}, - api_version="2024-12-30", - ).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_servers_list(self, resource_group): + response = self.client.servers.list() + result = [r for r in response] # please add some check logic here by yourself # ... @@ -255,7 +252,6 @@ def test_servers_begin_failover(self, resource_group): response = self.client.servers.begin_failover( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -263,13 +259,16 @@ def test_servers_begin_failover(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_servers_begin_reset_gtid(self, resource_group): - response = self.client.servers.begin_reset_gtid( + def test_servers_validate_estimate_high_availability(self, resource_group): + response = self.client.servers.validate_estimate_high_availability( resource_group_name=resource_group.name, server_name="str", - parameters={"gtidSet": "str"}, - api_version="2024-12-30", - ).result() # call '.result()' to poll until service return final result + parameters={ + "estimatedDowntime": 0, + "expectedStandbyAvailabilityZone": "str", + "scheduledStandbyAvailabilityZone": "str", + }, + ) # please add some check logic here by yourself # ... @@ -281,7 +280,6 @@ def test_servers_begin_restart(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={"maxFailoverSeconds": 0, "restartWithFailover": "str"}, - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -293,7 +291,6 @@ def test_servers_begin_start(self, resource_group): response = self.client.servers.begin_start( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -305,7 +302,6 @@ def test_servers_begin_stop(self, resource_group): response = self.client.servers.begin_stop( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -313,17 +309,24 @@ def test_servers_begin_stop(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_servers_validate_estimate_high_availability(self, resource_group): - response = self.client.servers.validate_estimate_high_availability( + def test_servers_begin_reset_gtid(self, resource_group): + response = self.client.servers.begin_reset_gtid( resource_group_name=resource_group.name, server_name="str", - parameters={ - "estimatedDowntime": 0, - "expectedStandbyAvailabilityZone": "str", - "scheduledStandbyAvailabilityZone": "str", - }, - api_version="2024-12-30", - ) + parameters={"gtidSet": "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_begin_detach_v_net(self, resource_group): + response = self.client.servers.begin_detach_v_net( + resource_group_name=resource_group.name, + server_name="str", + parameters={"publicNetworkAccess": "str"}, + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations_async.py index 8df554637643..fa5470f70906 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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,34 +19,12 @@ class TestMySQLManagementServersOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_servers_list(self, resource_group): - response = self.client.servers.list( - api_version="2024-12-30", - ) - 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-12-30", - ) - 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-12-30", ) # please add some check logic here by yourself @@ -61,27 +39,6 @@ async def test_servers_begin_create(self, resource_group): server_name="str", parameters={ "location": "str", - "administratorLogin": "str", - "administratorLoginPassword": "str", - "availabilityZone": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "createMode": "str", - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "databasePort": 0, - "fullVersion": "str", - "fullyQualifiedDomainName": "str", - "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, "id": "str", "identity": { "principalId": "str", @@ -89,64 +46,96 @@ async def test_servers_begin_create(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "importSourceProperties": { - "dataDirPath": "str", - "sasToken": "str", - "storageType": "str", - "storageUrl": "str", - }, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, "name": "str", - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", - }, - "privateEndpointConnections": [ - { - "groupIds": ["str"], - "id": "str", - "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "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", - }, + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "availabilityZone": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "createMode": "str", + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", "type": "str", - } - ], - "replicaCapacity": 0, - "replicationRole": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sku": {"name": "str", "tier": "str"}, - "sourceServerResourceId": "str", - "state": "str", - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "LocalRedundancy", - "storageSizeGB": 0, - "storageSku": "str", + }, + "databasePort": 0, + "fullVersion": "str", + "fullyQualifiedDomainName": "str", + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, + "importSourceProperties": { + "dataDirPath": "str", + "sasToken": "str", + "storageType": "str", + "storageUrl": "str", + }, + "lowerCaseTableNames": 0, + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", + }, + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "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", + } + ], + "replicaCapacity": 0, + "replicationRole": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sourceServerResourceId": "str", + "state": "str", + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "str", + "storageSizeGB": 0, + "storageSku": "str", + }, + "version": "str", }, + "sku": {"name": "str", "tier": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -157,9 +146,7 @@ async def test_servers_begin_create(self, resource_group): }, "tags": {"str": "str"}, "type": "str", - "version": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -174,55 +161,61 @@ async def test_servers_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "administratorLoginPassword": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "highAvailability": {"mode": "str", "standbyAvailabilityZone": "str", "state": "str"}, "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", + "properties": { + "administratorLoginPassword": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", + }, + "replicationRole": "str", + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "str", + "storageSizeGB": 0, + "storageSku": "str", + }, + "version": "str", }, - "replicationRole": "str", "sku": {"name": "str", "tier": "str"}, - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "LocalRedundancy", - "storageSizeGB": 0, - "storageSku": "str", - }, "tags": {"str": "str"}, - "version": "str", }, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -236,7 +229,6 @@ async def test_servers_begin_delete(self, resource_group): await self.client.servers.begin_delete( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -245,16 +237,19 @@ async def test_servers_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_servers_begin_detach_v_net(self, resource_group): - response = await ( - await self.client.servers.begin_detach_v_net( - resource_group_name=resource_group.name, - server_name="str", - parameters={"publicNetworkAccess": "str"}, - api_version="2024-12-30", - ) - ).result() # call '.result()' to poll until service return final result + 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 # ... @@ -265,7 +260,6 @@ async def test_servers_begin_failover(self, resource_group): await self.client.servers.begin_failover( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -274,15 +268,16 @@ async def test_servers_begin_failover(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_servers_begin_reset_gtid(self, resource_group): - response = await ( - await self.client.servers.begin_reset_gtid( - resource_group_name=resource_group.name, - server_name="str", - parameters={"gtidSet": "str"}, - api_version="2024-12-30", - ) - ).result() # call '.result()' to poll until service return final result + async def test_servers_validate_estimate_high_availability(self, resource_group): + response = await self.client.servers.validate_estimate_high_availability( + resource_group_name=resource_group.name, + server_name="str", + parameters={ + "estimatedDowntime": 0, + "expectedStandbyAvailabilityZone": "str", + "scheduledStandbyAvailabilityZone": "str", + }, + ) # please add some check logic here by yourself # ... @@ -295,7 +290,6 @@ async def test_servers_begin_restart(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={"maxFailoverSeconds": 0, "restartWithFailover": "str"}, - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -309,7 +303,6 @@ async def test_servers_begin_start(self, resource_group): await self.client.servers.begin_start( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -323,7 +316,6 @@ async def test_servers_begin_stop(self, resource_group): await self.client.servers.begin_stop( resource_group_name=resource_group.name, server_name="str", - api_version="2024-12-30", ) ).result() # call '.result()' to poll until service return final result @@ -332,17 +324,28 @@ async def test_servers_begin_stop(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_servers_validate_estimate_high_availability(self, resource_group): - response = await self.client.servers.validate_estimate_high_availability( - resource_group_name=resource_group.name, - server_name="str", - parameters={ - "estimatedDowntime": 0, - "expectedStandbyAvailabilityZone": "str", - "scheduledStandbyAvailabilityZone": "str", - }, - api_version="2024-12-30", - ) + async def test_servers_begin_reset_gtid(self, resource_group): + response = await ( + await self.client.servers.begin_reset_gtid( + resource_group_name=resource_group.name, + server_name="str", + parameters={"gtidSet": "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_begin_detach_v_net(self, resource_group): + response = await ( + await self.client.servers.begin_detach_v_net( + resource_group_name=resource_group.name, + server_name="str", + parameters={"publicNetworkAccess": "str"}, + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml index ce7ff70e1e7c..082967ba81a2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml @@ -13,7 +13,7 @@ authors = [ description = "Microsoft Azure Mysqlflexibleservers Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", @@ -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", ] @@ -79,7 +79,7 @@ package_name = "azure-mgmt-mysqlflexibleservers" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Mysqlflexibleservers Management" package_doc_id = "" -is_stable = true +is_stable = false is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml new file mode 100644 index 000000000000..8360c1d67ad5 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers +commit: 1d3ac611f503e05650fb85520582b06140d2599e +repo: Azure/azure-rest-api-specs +additionalDirectories: From 1b688fe1ab44fffaed3d4dda54ee28a4c0d2909e Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 Date: Tue, 11 Nov 2025 17:40:28 +0800 Subject: [PATCH 2/4] update changelog --- .../azure-mgmt-mysqlflexibleservers/CHANGELOG.md | 10 ++++++---- .../azure/mgmt/mysqlflexibleservers/_version.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md index 7508e1d0e116..fd6247018e20 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.0b4 (2025-11-11) +## 1.1.0b1 (2025-11-11) ### Features Added @@ -29,12 +29,14 @@ - Added model `ServerBackupPropertiesV2` - Added model `ServerPropertiesForUpdate` - Added model `ValidateBackupResponseProperties` - - Model `LongRunningBackupOperations` added method `begin_delete` - - Added model `PrivateEndpointConnectionsOperations` - - Added model `PrivateLinkResourcesOperations` + - Added operation group `PrivateEndpointConnectionsOperations` + - Added operation group `PrivateLinkResourcesOperations` + - Operation group `LongRunningBackupOperations` added method `begin_delete` ### Breaking Changes + - This version introduces new hybrid models which have dual dictionary and model nature. And please follow https://aka.ms/azsdk/python/migrate/hybrid-models for migration. + - For the method breakings, please refer to https://aka.ms/azsdk/python/migrate/operations for mgration. - Model `AdvancedThreatProtectionForUpdate` deleted or renamed its instance variable `state` - Model `AzureADAdministrator` deleted or renamed its instance variable `administrator_type` - Model `AzureADAdministrator` deleted or renamed its instance variable `login` diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py index 22553b18fb7e..a1f432eddc4e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b4" +VERSION = "1.1.0b1" From 5db4478c4cef75e1a776ac2c86632456339c862a Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 19 Nov 2025 03:03:15 +0000 Subject: [PATCH 3/4] Configurations: 'specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/readme.md', API Version: 2025-06-01-preview, SDK Release Type: beta, and CommitSHA: 'b61ac84b569118b89c1ebce6bdb94600c58e1066' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=5588110 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- .../CHANGELOG.md | 10 + .../_metadata.json | 11 +- .../apiview-properties.json | 516 +- .../mgmt/mysqlflexibleservers/__init__.py | 4 +- .../mysqlflexibleservers/_configuration.py | 13 +- ...client.py => _my_sql_management_client.py} | 151 +- .../mysqlflexibleservers/_utils/__init__.py | 2 +- .../mysqlflexibleservers/_utils/model_base.py | 1237 -- .../_utils/serialization.py | 2 +- .../mgmt/mysqlflexibleservers/_validation.py | 66 - .../mgmt/mysqlflexibleservers/aio/__init__.py | 4 +- .../aio/_configuration.py | 13 +- ...client.py => _my_sql_management_client.py} | 151 +- .../aio/operations/__init__.py | 75 +- ...d_threat_protection_settings_operations.py | 678 + .../_azure_ad_administrators_operations.py | 575 + .../_backup_and_export_operations.py | 327 + .../aio/operations/_backups_operations.py | 272 + .../_check_name_availability_operations.py | 177 + ...vailability_without_location_operations.py | 161 + ...virtual_network_subnet_usage_operations.py | 171 + .../operations/_configurations_operations.py | 884 ++ .../aio/operations/_databases_operations.py | 557 + .../operations/_firewall_rules_operations.py | 560 + ..._get_private_dns_zone_suffix_operations.py | 104 + ..._location_based_capabilities_operations.py | 138 + ...ocation_based_capability_set_operations.py | 196 + .../aio/operations/_log_files_operations.py | 143 + .../_long_running_backup_operations.py | 407 + .../_long_running_backups_operations.py | 208 + .../operations/_maintenances_operations.py | 433 + .../_operation_progress_operations.py | 113 + .../_operation_results_operations.py | 113 + .../aio/operations/_operations.py | 9408 +------------ ...private_endpoint_connections_operations.py | 536 + .../_private_link_resources_operations.py | 178 + .../aio/operations/_replicas_operations.py | 142 + .../_servers_migration_operations.py | 182 + .../aio/operations/_servers_operations.py | 1903 +++ .../mysqlflexibleservers/models/__init__.py | 70 +- .../mysqlflexibleservers/models/_models.py | 4289 ------ .../models/_models_py3.py | 4066 ++++++ ....py => _my_sql_management_client_enums.py} | 27 +- .../operations/__init__.py | 75 +- ...d_threat_protection_settings_operations.py | 840 ++ .../_azure_ad_administrators_operations.py | 730 + .../_backup_and_export_operations.py | 403 + .../operations/_backups_operations.py | 376 + .../_check_name_availability_operations.py | 210 + ...vailability_without_location_operations.py | 192 + ...virtual_network_subnet_usage_operations.py | 205 + .../operations/_configurations_operations.py | 1075 ++ .../operations/_databases_operations.py | 694 + .../operations/_firewall_rules_operations.py | 705 + ..._get_private_dns_zone_suffix_operations.py | 125 + ..._location_based_capabilities_operations.py | 168 + ...ocation_based_capability_set_operations.py | 258 + .../operations/_log_files_operations.py | 178 + .../_long_running_backup_operations.py | 481 + .../_long_running_backups_operations.py | 276 + .../operations/_maintenances_operations.py | 542 + .../_operation_progress_operations.py | 145 + .../_operation_results_operations.py | 145 + .../operations/_operations.py | 11178 +--------------- ...private_endpoint_connections_operations.py | 697 + .../_private_link_resources_operations.py | 252 + .../operations/_replicas_operations.py | 178 + .../_servers_migration_operations.py | 216 + .../operations/_servers_operations.py | 2327 ++++ ...advanced_threat_protection_settings_get.py | 7 +- ...dvanced_threat_protection_settings_list.py | 7 +- ...reat_protection_settings_patch_disabled.py | 7 +- ...hreat_protection_settings_patch_enabled.py | 7 +- ...threat_protection_settings_put_disabled.py | 7 +- ..._threat_protection_settings_put_enabled.py | 7 +- .../azure_ad_administrator_create.py | 6 +- .../azure_ad_administrator_delete.py | 7 +- .../azure_ad_administrator_get.py | 7 +- .../azure_ad_administrators_list_by_server.py | 7 +- .../generated_samples/backup_and_export.py | 7 +- .../generated_samples/backup_get.py | 7 +- .../generated_samples/backup_put.py | 7 +- .../backups_list_by_server.py | 7 +- .../capabilities_by_location_list.py | 7 +- .../capability_set_by_location.py | 8 +- .../capability_set_list_by_location.py | 7 +- .../check_name_availability.py | 7 +- ...heck_name_availability_without_location.py | 7 +- .../check_virtual_network_subnet_usage.py | 6 +- .../configuration_create_or_update.py | 7 +- .../generated_samples/configuration_get.py | 7 +- .../generated_samples/configuration_update.py | 7 +- .../configurations_batch_update.py | 7 +- .../configurations_list_by_server.py | 7 +- .../generated_samples/cutover_migration.py | 7 +- .../generated_samples/database_create.py | 7 +- .../generated_samples/database_delete.py | 7 +- .../generated_samples/database_get.py | 7 +- .../databases_list_by_server.py | 7 +- .../generated_samples/firewall_rule_create.py | 7 +- .../generated_samples/firewall_rule_delete.py | 7 +- .../generated_samples/firewall_rule_get.py | 7 +- .../firewall_rules_list_by_server.py | 7 +- .../get_private_dns_zone_suffix.py | 5 +- .../log_files_list_by_server.py | 7 +- .../generated_samples/long_running_backup.py | 7 +- .../long_running_backup_delete.py | 7 +- .../long_running_backup_get.py | 7 +- .../long_running_backups_list_by_server.py | 7 +- ...ance_policy_patch_opt_in_virtual_canary.py | 7 +- ...nce_policy_patch_opt_out_virtual_canary.py | 7 +- .../generated_samples/maintenance_read.py | 7 +- .../generated_samples/maintenance_update.py | 7 +- .../maintenances_list_by_server.py | 7 +- ...peration_progress_get_backup_and_export.py | 7 +- ...ration_progress_get_import_from_storage.py | 7 +- .../operation_results_get.py | 7 +- .../generated_samples/operations_list.py | 5 +- .../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 | 10 +- .../replicas_list_by_server.py | 7 +- .../generated_samples/server_create.py | 7 +- .../server_create_replica.py | 6 +- .../server_create_with_byok.py | 6 +- .../server_create_with_database_port.py | 7 +- ...rver_create_with_lower_case_table_names.py | 7 +- ...erver_create_with_point_in_time_restore.py | 6 +- .../generated_samples/server_delete.py | 7 +- .../generated_samples/server_detach_vnet.py | 7 +- .../generated_samples/server_failover.py | 7 +- .../generated_samples/server_get.py | 7 +- .../generated_samples/server_get_with_vnet.py | 7 +- .../generated_samples/server_reset_gtid.py | 7 +- .../generated_samples/server_restart.py | 7 +- .../generated_samples/server_start.py | 7 +- .../generated_samples/server_stop.py | 7 +- .../generated_samples/server_update.py | 7 +- .../server_update_with_byok.py | 6 +- ...update_with_customer_maintenance_window.py | 7 +- ...ver_validate_estimate_high_availability.py | 7 +- .../generated_samples/servers_list.py | 7 +- .../servers_list_by_resource_group.py | 7 +- .../generated_samples/validate_backup.py | 7 +- .../generated_tests/conftest.py | 2 +- ...d_threat_protection_settings_operations.py | 34 +- ...at_protection_settings_operations_async.py | 34 +- ...ment_azure_ad_administrators_operations.py | 40 +- ...zure_ad_administrators_operations_async.py | 40 +- ...management_backup_and_export_operations.py | 4 +- ...ment_backup_and_export_operations_async.py | 4 +- ...st_my_sql_management_backups_operations.py | 23 +- ...sql_management_backups_operations_async.py | 23 +- ...ment_check_name_availability_operations.py | 3 +- ...heck_name_availability_operations_async.py | 3 +- ...vailability_without_location_operations.py | 3 +- ...ility_without_location_operations_async.py | 3 +- ...virtual_network_subnet_usage_operations.py | 3 +- ...l_network_subnet_usage_operations_async.py | 3 +- ...ql_management_configurations_operations.py | 82 +- ...agement_configurations_operations_async.py | 82 +- ..._my_sql_management_databases_operations.py | 31 +- ...l_management_databases_operations_async.py | 31 +- ...ql_management_firewall_rules_operations.py | 31 +- ...agement_firewall_rules_operations_async.py | 31 +- ..._get_private_dns_zone_suffix_operations.py | 6 +- ...rivate_dns_zone_suffix_operations_async.py | 6 +- ..._location_based_capabilities_operations.py | 3 +- ...ion_based_capabilities_operations_async.py | 3 +- ...ocation_based_capability_set_operations.py | 18 +- ...n_based_capability_set_operations_async.py | 18 +- ..._my_sql_management_log_files_operations.py | 3 +- ...l_management_log_files_operations_async.py | 3 +- ...nagement_long_running_backup_operations.py | 4 +- ...nt_long_running_backup_operations_async.py | 4 +- ...agement_long_running_backups_operations.py | 18 +- ...t_long_running_backups_operations_async.py | 18 +- ..._sql_management_maintenances_operations.py | 27 +- ...anagement_maintenances_operations_async.py | 27 +- ...anagement_operation_progress_operations.py | 3 +- ...ent_operation_progress_operations_async.py | 3 +- ...management_operation_results_operations.py | 3 +- ...ment_operation_results_operations_async.py | 3 +- .../test_my_sql_management_operations.py | 6 +- ...test_my_sql_management_operations_async.py | 6 +- ...private_endpoint_connections_operations.py | 42 +- ...e_endpoint_connections_operations_async.py | 44 +- ...ement_private_link_resources_operations.py | 16 +- ...private_link_resources_operations_async.py | 16 +- ...t_my_sql_management_replicas_operations.py | 3 +- ...ql_management_replicas_operations_async.py | 3 +- ...management_servers_migration_operations.py | 3 +- ...ment_servers_migration_operations_async.py | 3 +- ...st_my_sql_management_servers_operations.py | 344 +- ...sql_management_servers_operations_async.py | 362 +- .../pyproject.toml | 2 +- .../tsp-location.yaml | 4 - 200 files changed, 26356 insertions(+), 27664 deletions(-) rename sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/{_client.py => _my_sql_management_client.py} (93%) delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_validation.py rename sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/{_client.py => _my_sql_management_client.py} (94%) create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py rename sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/{_enums.py => _my_sql_management_client_enums.py} (90%) create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_link_resources_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py create mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py delete mode 100644 sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md index fd6247018e20..3452d0e5cca6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 1.1.0b1 (2025-11-19) + +### Features Added + + - Model `HighAvailability` added property `replication_mode` + - Model `Server` added property `lower_case_table_names` + - Enum `ServerVersion` added member `EIGHT4` + - Added enum `ReplicationMode` + - Model `LongRunningBackupOperations` added method `begin_delete` + ## 1.1.0b1 (2025-11-11) ### Features Added diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json index e2613d87ba4d..28bd4c35417f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/_metadata.json @@ -1,7 +1,14 @@ { "apiVersion": "2025-06-01-preview", - "commit": "1d3ac611f503e05650fb85520582b06140d2599e", + "commit": "b61ac84b569118b89c1ebce6bdb94600c58e1066", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers", - "emitterVersion": "0.53.1" + "emitterVersion": "0.53.1", + "autorest": "3.10.2", + "use": [ + "@autorest/python@6.42.0", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/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.42.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/readme.md" } \ No newline at end of file diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json index 90a7507d6ffd..af3f514b2dbe 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/apiview-properties.json @@ -1,265 +1,259 @@ { - "CrossLanguagePackageId": "Microsoft.DBforMySQL", + "CrossLanguagePackageId": null, "CrossLanguageDefinitionId": { - "azure.mgmt.mysqlflexibleservers.models.AdministratorProperties": "Microsoft.DBforMySQL.AdministratorProperties", - "azure.mgmt.mysqlflexibleservers.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", - "azure.mgmt.mysqlflexibleservers.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection": "Microsoft.DBforMySQL.AdvancedThreatProtection", - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate": "Microsoft.DBforMySQL.AdvancedThreatProtectionForUpdate", - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProperties": "Microsoft.DBforMySQL.AdvancedThreatProtectionProperties", - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionUpdateProperties": "Microsoft.DBforMySQL.AdvancedThreatProtectionUpdateProperties", - "azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator": "Microsoft.DBforMySQL.AzureADAdministrator", - "azure.mgmt.mysqlflexibleservers.models.Backup": "Microsoft.DBforMySQL.Backup", - "azure.mgmt.mysqlflexibleservers.models.BackupRequestBase": "Microsoft.DBforMySQL.BackupRequestBase", - "azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest": "Microsoft.DBforMySQL.BackupAndExportRequest", - "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse": "Microsoft.DBforMySQL.BackupAndExportResponse", - "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseProperties": "Microsoft.DBforMySQL.BackupAndExportResponseProperties", - "azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType": "Microsoft.DBforMySQL.OperationProgressResponseType", - "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseType": "Microsoft.DBforMySQL.BackupAndExportResponseType", - "azure.mgmt.mysqlflexibleservers.models.BackupSettings": "Microsoft.DBforMySQL.BackupSettings", - "azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails": "Microsoft.DBforMySQL.BackupStoreDetails", - "azure.mgmt.mysqlflexibleservers.models.Capability": "Microsoft.DBforMySQL.Capability", - "azure.mgmt.mysqlflexibleservers.models.CapabilityProperties": "Microsoft.DBforMySQL.CapabilityProperties", - "azure.mgmt.mysqlflexibleservers.models.CapabilityPropertiesV2": "Microsoft.DBforMySQL.CapabilityPropertiesV2", - "azure.mgmt.mysqlflexibleservers.models.Configuration": "Microsoft.DBforMySQL.Configuration", - "azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate": "Microsoft.DBforMySQL.ConfigurationForBatchUpdate", - "azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdateProperties": "Microsoft.DBforMySQL.ConfigurationForBatchUpdateProperties", - "azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate": "Microsoft.DBforMySQL.ConfigurationListForBatchUpdate", - "azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult": "Microsoft.DBforMySQL.ConfigurationListResult", - "azure.mgmt.mysqlflexibleservers.models.ConfigurationProperties": "Microsoft.DBforMySQL.ConfigurationProperties", - "azure.mgmt.mysqlflexibleservers.models.Database": "Microsoft.DBforMySQL.Database", - "azure.mgmt.mysqlflexibleservers.models.DatabaseProperties": "Microsoft.DBforMySQL.DatabaseProperties", - "azure.mgmt.mysqlflexibleservers.models.DataEncryption": "Microsoft.DBforMySQL.DataEncryption", - "azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage": "Microsoft.DBforMySQL.DelegatedSubnetUsage", - "azure.mgmt.mysqlflexibleservers.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", - "azure.mgmt.mysqlflexibleservers.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", - "azure.mgmt.mysqlflexibleservers.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", - "azure.mgmt.mysqlflexibleservers.models.FeatureProperty": "Microsoft.DBforMySQL.FeatureProperty", - "azure.mgmt.mysqlflexibleservers.models.FirewallRule": "Microsoft.DBforMySQL.FirewallRule", - "azure.mgmt.mysqlflexibleservers.models.FirewallRuleProperties": "Microsoft.DBforMySQL.FirewallRuleProperties", - "azure.mgmt.mysqlflexibleservers.models.FullBackupStoreDetails": "Microsoft.DBforMySQL.FullBackupStoreDetails", - "azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse": "Microsoft.DBforMySQL.GetPrivateDnsZoneSuffixResponse", - "azure.mgmt.mysqlflexibleservers.models.HighAvailability": "Microsoft.DBforMySQL.HighAvailability", - "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation": "Microsoft.DBforMySQL.HighAvailabilityValidationEstimation", - "azure.mgmt.mysqlflexibleservers.models.ImportFromStorageResponseType": "Microsoft.DBforMySQL.ImportFromStorageResponseType", - "azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties": "Microsoft.DBforMySQL.ImportSourceProperties", - "azure.mgmt.mysqlflexibleservers.models.LogFile": "Microsoft.DBforMySQL.LogFile", - "azure.mgmt.mysqlflexibleservers.models.LogFileProperties": "Microsoft.DBforMySQL.LogFileProperties", - "azure.mgmt.mysqlflexibleservers.models.Maintenance": "Microsoft.DBforMySQL.Maintenance", - "azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy": "Microsoft.DBforMySQL.MaintenancePolicy", - "azure.mgmt.mysqlflexibleservers.models.MaintenanceProperties": "Microsoft.DBforMySQL.MaintenanceProperties", - "azure.mgmt.mysqlflexibleservers.models.MaintenancePropertiesForUpdate": "Microsoft.DBforMySQL.MaintenancePropertiesForUpdate", - "azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate": "Microsoft.DBforMySQL.MaintenanceUpdate", - "azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow": "Microsoft.DBforMySQL.MaintenanceWindow", - "azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity": "Microsoft.DBforMySQL.MySQLServerIdentity", - "azure.mgmt.mysqlflexibleservers.models.MySQLServerSku": "Microsoft.DBforMySQL.MySQLServerSku", - "azure.mgmt.mysqlflexibleservers.models.NameAvailability": "Microsoft.DBforMySQL.NameAvailability", - "azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest": "Microsoft.DBforMySQL.NameAvailabilityRequest", - "azure.mgmt.mysqlflexibleservers.models.Network": "Microsoft.DBforMySQL.Network", - "azure.mgmt.mysqlflexibleservers.models.Operation": "Microsoft.DBforMySQL.Operation", - "azure.mgmt.mysqlflexibleservers.models.OperationDisplay": "Microsoft.DBforMySQL.OperationDisplay", - "azure.mgmt.mysqlflexibleservers.models.OperationStatusResult": "Azure.ResourceManager.CommonTypes.OperationStatusResult", - "azure.mgmt.mysqlflexibleservers.models.OperationProgressResult": "Microsoft.DBforMySQL.OperationProgressResult", - "azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult": "Microsoft.DBforMySQL.OperationStatusExtendedResult", - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint": "Azure.ResourceManager.CommonTypes.PrivateEndpoint", - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection": "Microsoft.DBforMySQL.PrivateEndpointConnection", - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult": "Azure.ResourceManager.ResourceListResult", - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProperties": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties", - "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource": "Azure.ResourceManager.CommonTypes.PrivateLinkResource", - "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceProperties": "Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties", - "azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState": "Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState", - "azure.mgmt.mysqlflexibleservers.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", - "azure.mgmt.mysqlflexibleservers.models.Server": "Microsoft.DBforMySQL.Server", - "azure.mgmt.mysqlflexibleservers.models.ServerBackup": "Microsoft.DBforMySQL.ServerBackup", - "azure.mgmt.mysqlflexibleservers.models.ServerBackupProperties": "Microsoft.DBforMySQL.ServerBackupProperties", - "azure.mgmt.mysqlflexibleservers.models.ServerBackupPropertiesV2": "Microsoft.DBforMySQL.ServerBackupPropertiesV2", - "azure.mgmt.mysqlflexibleservers.models.ServerBackupV2": "Microsoft.DBforMySQL.ServerBackupV2", - "azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter": "Microsoft.DBforMySQL.ServerDetachVNetParameter", - "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability": "Microsoft.DBforMySQL.ServerEditionCapability", - "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2": "Microsoft.DBforMySQL.ServerEditionCapabilityV2", - "azure.mgmt.mysqlflexibleservers.models.ServerForUpdate": "Microsoft.DBforMySQL.ServerForUpdate", - "azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter": "Microsoft.DBforMySQL.ServerGtidSetParameter", - "azure.mgmt.mysqlflexibleservers.models.ServerProperties": "Microsoft.DBforMySQL.ServerProperties", - "azure.mgmt.mysqlflexibleservers.models.ServerPropertiesForUpdate": "Microsoft.DBforMySQL.ServerPropertiesForUpdate", - "azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter": "Microsoft.DBforMySQL.ServerRestartParameter", - "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability": "Microsoft.DBforMySQL.ServerVersionCapability", - "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2": "Microsoft.DBforMySQL.ServerVersionCapabilityV2", - "azure.mgmt.mysqlflexibleservers.models.SkuCapability": "Microsoft.DBforMySQL.SkuCapability", - "azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2": "Microsoft.DBforMySQL.SkuCapabilityV2", - "azure.mgmt.mysqlflexibleservers.models.Storage": "Microsoft.DBforMySQL.Storage", - "azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability": "Microsoft.DBforMySQL.StorageEditionCapability", - "azure.mgmt.mysqlflexibleservers.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", - "azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity": "Microsoft.DBforMySQL.UserAssignedIdentity", - "azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse": "Microsoft.DBforMySQL.ValidateBackupResponse", - "azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponseProperties": "Microsoft.DBforMySQL.ValidateBackupResponseProperties", - "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter": "Microsoft.DBforMySQL.VirtualNetworkSubnetUsageParameter", - "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult": "Microsoft.DBforMySQL.VirtualNetworkSubnetUsageResult", - "azure.mgmt.mysqlflexibleservers.models.Origin": "Microsoft.DBforMySQL.Origin", - "azure.mgmt.mysqlflexibleservers.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", - "azure.mgmt.mysqlflexibleservers.models.AdministratorType": "Microsoft.DBforMySQL.AdministratorType", - "azure.mgmt.mysqlflexibleservers.models.AdministratorName": "Microsoft.DBforMySQL.AdministratorName", - "azure.mgmt.mysqlflexibleservers.models.ServerVersion": "Microsoft.DBforMySQL.ServerVersion", - "azure.mgmt.mysqlflexibleservers.models.CreateMode": "Microsoft.DBforMySQL.CreateMode", - "azure.mgmt.mysqlflexibleservers.models.ReplicationRole": "Microsoft.DBforMySQL.ReplicationRole", - "azure.mgmt.mysqlflexibleservers.models.DataEncryptionType": "Microsoft.DBforMySQL.DataEncryptionType", - "azure.mgmt.mysqlflexibleservers.models.ServerState": "Microsoft.DBforMySQL.ServerState", - "azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum": "Microsoft.DBforMySQL.EnableStatusEnum", - "azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum": "Microsoft.DBforMySQL.StorageRedundancyEnum", - "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode": "Microsoft.DBforMySQL.HighAvailabilityMode", - "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState": "Microsoft.DBforMySQL.HighAvailabilityState", - "azure.mgmt.mysqlflexibleservers.models.ReplicationMode": "Microsoft.DBforMySQL.replicationMode", - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus": "Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus", - "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState", - "azure.mgmt.mysqlflexibleservers.models.PatchStrategy": "Microsoft.DBforMySQL.PatchStrategy", - "azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance": "Microsoft.DBforMySQL.BatchOfMaintenance", - "azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType": "Microsoft.DBforMySQL.ImportSourceStorageType", - "azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType": "Microsoft.DBforMySQL.ManagedServiceIdentityType", - "azure.mgmt.mysqlflexibleservers.models.ServerSkuTier": "Microsoft.DBforMySQL.ServerSkuTier", - "azure.mgmt.mysqlflexibleservers.models.OperationStatus": "Microsoft.DBforMySQL.OperationStatus", - "azure.mgmt.mysqlflexibleservers.models.BackupFormat": "Microsoft.DBforMySQL.BackupFormat", - "azure.mgmt.mysqlflexibleservers.models.BackupType": "Microsoft.DBforMySQL.BackupType", - "azure.mgmt.mysqlflexibleservers.models.ProvisioningState": "Microsoft.DBforMySQL.ProvisioningState", - "azure.mgmt.mysqlflexibleservers.models.ConfigurationSource": "Microsoft.DBforMySQL.ConfigurationSource", - "azure.mgmt.mysqlflexibleservers.models.IsReadOnly": "Microsoft.DBforMySQL.IsReadOnly", - "azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart": "Microsoft.DBforMySQL.IsConfigPendingRestart", - "azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig": "Microsoft.DBforMySQL.IsDynamicConfig", - "azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault": "Microsoft.DBforMySQL.ResetAllToDefault", - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState": "Microsoft.DBforMySQL.AdvancedThreatProtectionState", - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState": "Microsoft.DBforMySQL.AdvancedThreatProtectionProvisioningState", - "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionName": "Microsoft.DBforMySQL.AdvancedThreatProtectionName", - "azure.mgmt.mysqlflexibleservers.models.MaintenanceType": "Microsoft.DBforMySQL.MaintenanceType", - "azure.mgmt.mysqlflexibleservers.models.MaintenanceState": "Microsoft.DBforMySQL.MaintenanceState", - "azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState": "Microsoft.DBforMySQL.MaintenanceProvisioningState", - "azure.mgmt.mysqlflexibleservers.models.ObjectType": "Microsoft.DBforMySQL.ObjectType", - "azure.mgmt.mysqlflexibleservers.operations.Operations.list": "Microsoft.DBforMySQL.Operations.list", - "azure.mgmt.mysqlflexibleservers.aio.operations.Operations.list": "Microsoft.DBforMySQL.Operations.list", - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.get": "Microsoft.DBforMySQL.AzureADAdministrators.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.get": "Microsoft.DBforMySQL.AzureADAdministrators.get", - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_create_or_update": "Microsoft.DBforMySQL.AzureADAdministrators.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_create_or_update": "Microsoft.DBforMySQL.AzureADAdministrators.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_delete": "Microsoft.DBforMySQL.AzureADAdministrators.delete", - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_delete": "Microsoft.DBforMySQL.AzureADAdministrators.delete", - "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.list_by_server": "Microsoft.DBforMySQL.AzureADAdministrators.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.list_by_server": "Microsoft.DBforMySQL.AzureADAdministrators.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.get": "Microsoft.DBforMySQL.Servers.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.get": "Microsoft.DBforMySQL.Servers.get", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_create": "Microsoft.DBforMySQL.Servers.create", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_create": "Microsoft.DBforMySQL.Servers.create", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_update": "Microsoft.DBforMySQL.Servers.update", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_update": "Microsoft.DBforMySQL.Servers.update", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_delete": "Microsoft.DBforMySQL.Servers.delete", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_delete": "Microsoft.DBforMySQL.Servers.delete", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list_by_resource_group": "Microsoft.DBforMySQL.Servers.listByResourceGroup", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list_by_resource_group": "Microsoft.DBforMySQL.Servers.listByResourceGroup", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list": "Microsoft.DBforMySQL.Servers.list", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list": "Microsoft.DBforMySQL.Servers.list", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_failover": "Microsoft.DBforMySQL.Servers.failover", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_failover": "Microsoft.DBforMySQL.Servers.failover", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.validate_estimate_high_availability": "Microsoft.DBforMySQL.Servers.validateEstimateHighAvailability", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.validate_estimate_high_availability": "Microsoft.DBforMySQL.Servers.validateEstimateHighAvailability", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_restart": "Microsoft.DBforMySQL.Servers.restart", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_restart": "Microsoft.DBforMySQL.Servers.restart", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_start": "Microsoft.DBforMySQL.Servers.start", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_start": "Microsoft.DBforMySQL.Servers.start", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_stop": "Microsoft.DBforMySQL.Servers.stop", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_stop": "Microsoft.DBforMySQL.Servers.stop", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_reset_gtid": "Microsoft.DBforMySQL.Servers.resetGtid", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_reset_gtid": "Microsoft.DBforMySQL.Servers.resetGtid", - "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_detach_v_net": "Microsoft.DBforMySQL.Servers.detachVNet", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_detach_v_net": "Microsoft.DBforMySQL.Servers.detachVNet", - "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.begin_create": "Microsoft.DBforMySQL.BackupAndExport.create", - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.begin_create": "Microsoft.DBforMySQL.BackupAndExport.create", - "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.validate_backup": "Microsoft.DBforMySQL.BackupAndExport.validateBackup", - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.validate_backup": "Microsoft.DBforMySQL.BackupAndExport.validateBackup", - "azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations.list_by_server": "Microsoft.DBforMySQL.LogFiles.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations.list_by_server": "Microsoft.DBforMySQL.LogFiles.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations.begin_cutover_migration": "Microsoft.DBforMySQL.ServersMigration.cutoverMigration", - "azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations.begin_cutover_migration": "Microsoft.DBforMySQL.ServersMigration.cutoverMigration", - "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.get": "Microsoft.DBforMySQL.Backups.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.get": "Microsoft.DBforMySQL.Backups.get", - "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.put": "Microsoft.DBforMySQL.Backups.put", - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.put": "Microsoft.DBforMySQL.Backups.put", - "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.list_by_server": "Microsoft.DBforMySQL.Backups.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.list_by_server": "Microsoft.DBforMySQL.Backups.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.get": "Microsoft.DBforMySQL.LongRunningBackups.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.get": "Microsoft.DBforMySQL.LongRunningBackups.get", - "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.list": "Microsoft.DBforMySQL.LongRunningBackups.list", - "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.list": "Microsoft.DBforMySQL.LongRunningBackups.list", - "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations.begin_create": "Microsoft.DBforMySQL.LongRunningBackup.create", - "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupOperations.begin_create": "Microsoft.DBforMySQL.LongRunningBackup.create", - "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations.begin_delete": "Microsoft.DBforMySQL.LongRunningBackup.delete", - "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupOperations.begin_delete": "Microsoft.DBforMySQL.LongRunningBackup.delete", - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.get": "Microsoft.DBforMySQL.Configurations.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.get": "Microsoft.DBforMySQL.Configurations.get", - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_create_or_update": "Microsoft.DBforMySQL.Configurations.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_create_or_update": "Microsoft.DBforMySQL.Configurations.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_update": "Microsoft.DBforMySQL.Configurations.update", - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_update": "Microsoft.DBforMySQL.Configurations.update", - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.list_by_server": "Microsoft.DBforMySQL.Configurations.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.list_by_server": "Microsoft.DBforMySQL.Configurations.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_batch_update": "Microsoft.DBforMySQL.Configurations.batchUpdate", - "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_batch_update": "Microsoft.DBforMySQL.Configurations.batchUpdate", - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.get": "Microsoft.DBforMySQL.Databases.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.get": "Microsoft.DBforMySQL.Databases.get", - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_create_or_update": "Microsoft.DBforMySQL.Databases.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_create_or_update": "Microsoft.DBforMySQL.Databases.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_delete": "Microsoft.DBforMySQL.Databases.delete", - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_delete": "Microsoft.DBforMySQL.Databases.delete", - "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.list_by_server": "Microsoft.DBforMySQL.Databases.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.list_by_server": "Microsoft.DBforMySQL.Databases.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.get": "Microsoft.DBforMySQL.FirewallRules.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.get": "Microsoft.DBforMySQL.FirewallRules.get", - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DBforMySQL.FirewallRules.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DBforMySQL.FirewallRules.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_delete": "Microsoft.DBforMySQL.FirewallRules.delete", - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_delete": "Microsoft.DBforMySQL.FirewallRules.delete", - "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.list_by_server": "Microsoft.DBforMySQL.FirewallRules.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.list_by_server": "Microsoft.DBforMySQL.FirewallRules.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.get": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.get": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.get", - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.updatePut", - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.updatePut", - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.update", - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.update", - "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.list": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.list", - "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.list": "Microsoft.DBforMySQL.AdvancedThreatProtectionSettings.list", - "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.get": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.get": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.get", - "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.list", - "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilitySet.list", - "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.read": "Microsoft.DBforMySQL.Maintenances.read", - "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.read": "Microsoft.DBforMySQL.Maintenances.read", - "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.begin_update": "Microsoft.DBforMySQL.Maintenances.update", - "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.begin_update": "Microsoft.DBforMySQL.Maintenances.update", - "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.list": "Microsoft.DBforMySQL.Maintenances.list", - "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.list": "Microsoft.DBforMySQL.Maintenances.list", - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DBforMySQL.PrivateEndpointConnections.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DBforMySQL.PrivateEndpointConnections.get", - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.DBforMySQL.PrivateEndpointConnections.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.DBforMySQL.PrivateEndpointConnections.createOrUpdate", - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DBforMySQL.PrivateEndpointConnections.delete", - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DBforMySQL.PrivateEndpointConnections.delete", - "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.DBforMySQL.PrivateEndpointConnections.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.DBforMySQL.PrivateEndpointConnections.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.get": "Microsoft.DBforMySQL.PrivateLinkResources.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.get": "Microsoft.DBforMySQL.PrivateLinkResources.get", - "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.DBforMySQL.PrivateLinkResources.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.DBforMySQL.PrivateLinkResources.listByServer", - "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilities.list", - "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations.list": "Microsoft.DBforMySQL.LocationBasedCapabilities.list", - "azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations.execute": "Microsoft.DBforMySQL.CheckVirtualNetworkSubnetUsage.execute", - "azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations.execute": "Microsoft.DBforMySQL.CheckVirtualNetworkSubnetUsage.execute", - "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailability.execute", - "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailability.execute", - "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailabilityWithoutLocation.execute", - "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations.execute": "Microsoft.DBforMySQL.CheckNameAvailabilityWithoutLocation.execute", - "azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations.get": "Microsoft.DBforMySQL.OperationResults.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations.get": "Microsoft.DBforMySQL.OperationResults.get", - "azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations.get": "Microsoft.DBforMySQL.OperationProgress.get", - "azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations.get": "Microsoft.DBforMySQL.OperationProgress.get", - "azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations.execute": "Microsoft.DBforMySQL.GetPrivateDnsZoneSuffix.execute", - "azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations.execute": "Microsoft.DBforMySQL.GetPrivateDnsZoneSuffix.execute", - "azure.mgmt.mysqlflexibleservers.operations.ReplicasOperations.list_by_server": "Microsoft.DBforMySQL.Replicas.listByServer", - "azure.mgmt.mysqlflexibleservers.aio.operations.ReplicasOperations.list_by_server": "Microsoft.DBforMySQL.Replicas.listByServer" + "azure.mgmt.mysqlflexibleservers.models.AdministratorListResult": null, + "azure.mgmt.mysqlflexibleservers.models.Resource": null, + "azure.mgmt.mysqlflexibleservers.models.ProxyResource": null, + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection": null, + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate": null, + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionListResult": null, + "azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator": null, + "azure.mgmt.mysqlflexibleservers.models.Backup": null, + "azure.mgmt.mysqlflexibleservers.models.BackupRequestBase": null, + "azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest": null, + "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse": null, + "azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType": null, + "azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseType": null, + "azure.mgmt.mysqlflexibleservers.models.BackupSettings": null, + "azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails": null, + "azure.mgmt.mysqlflexibleservers.models.CapabilitiesListResult": null, + "azure.mgmt.mysqlflexibleservers.models.Capability": null, + "azure.mgmt.mysqlflexibleservers.models.CapabilityProperties": null, + "azure.mgmt.mysqlflexibleservers.models.CapabilitySetsList": null, + "azure.mgmt.mysqlflexibleservers.models.Configuration": null, + "azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate": null, + "azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate": null, + "azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult": null, + "azure.mgmt.mysqlflexibleservers.models.Database": null, + "azure.mgmt.mysqlflexibleservers.models.DatabaseListResult": null, + "azure.mgmt.mysqlflexibleservers.models.DataEncryption": null, + "azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage": null, + "azure.mgmt.mysqlflexibleservers.models.ErrorAdditionalInfo": null, + "azure.mgmt.mysqlflexibleservers.models.ErrorDetail": null, + "azure.mgmt.mysqlflexibleservers.models.ErrorResponse": null, + "azure.mgmt.mysqlflexibleservers.models.FeatureProperty": null, + "azure.mgmt.mysqlflexibleservers.models.FirewallRule": null, + "azure.mgmt.mysqlflexibleservers.models.FirewallRuleListResult": null, + "azure.mgmt.mysqlflexibleservers.models.FullBackupStoreDetails": null, + "azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse": null, + "azure.mgmt.mysqlflexibleservers.models.HighAvailability": null, + "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation": null, + "azure.mgmt.mysqlflexibleservers.models.ImportFromStorageResponseType": null, + "azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties": null, + "azure.mgmt.mysqlflexibleservers.models.LogFile": null, + "azure.mgmt.mysqlflexibleservers.models.LogFileListResult": null, + "azure.mgmt.mysqlflexibleservers.models.Maintenance": null, + "azure.mgmt.mysqlflexibleservers.models.MaintenanceListResult": null, + "azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy": null, + "azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate": null, + "azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow": null, + "azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity": null, + "azure.mgmt.mysqlflexibleservers.models.MySQLServerSku": null, + "azure.mgmt.mysqlflexibleservers.models.NameAvailability": null, + "azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest": null, + "azure.mgmt.mysqlflexibleservers.models.Network": null, + "azure.mgmt.mysqlflexibleservers.models.Operation": null, + "azure.mgmt.mysqlflexibleservers.models.OperationDisplay": null, + "azure.mgmt.mysqlflexibleservers.models.OperationListResult": null, + "azure.mgmt.mysqlflexibleservers.models.OperationStatusResult": null, + "azure.mgmt.mysqlflexibleservers.models.OperationProgressResult": null, + "azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceListResult": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState": null, + "azure.mgmt.mysqlflexibleservers.models.TrackedResource": null, + "azure.mgmt.mysqlflexibleservers.models.Server": null, + "azure.mgmt.mysqlflexibleservers.models.ServerBackup": null, + "azure.mgmt.mysqlflexibleservers.models.ServerBackupListResult": null, + "azure.mgmt.mysqlflexibleservers.models.ServerBackupV2": null, + "azure.mgmt.mysqlflexibleservers.models.ServerBackupV2ListResult": null, + "azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter": null, + "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability": null, + "azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2": null, + "azure.mgmt.mysqlflexibleservers.models.ServerForUpdate": null, + "azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter": null, + "azure.mgmt.mysqlflexibleservers.models.ServerListResult": null, + "azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter": null, + "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability": null, + "azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2": null, + "azure.mgmt.mysqlflexibleservers.models.SkuCapability": null, + "azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2": null, + "azure.mgmt.mysqlflexibleservers.models.Storage": null, + "azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability": null, + "azure.mgmt.mysqlflexibleservers.models.SystemData": null, + "azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity": null, + "azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse": null, + "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter": null, + "azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult": null, + "azure.mgmt.mysqlflexibleservers.models.Origin": null, + "azure.mgmt.mysqlflexibleservers.models.CreatedByType": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus": null, + "azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState": null, + "azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType": null, + "azure.mgmt.mysqlflexibleservers.models.ServerSkuTier": null, + "azure.mgmt.mysqlflexibleservers.models.ServerVersion": null, + "azure.mgmt.mysqlflexibleservers.models.CreateMode": null, + "azure.mgmt.mysqlflexibleservers.models.ReplicationRole": null, + "azure.mgmt.mysqlflexibleservers.models.DataEncryptionType": null, + "azure.mgmt.mysqlflexibleservers.models.ServerState": null, + "azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum": null, + "azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum": null, + "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode": null, + "azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState": null, + "azure.mgmt.mysqlflexibleservers.models.ReplicationMode": null, + "azure.mgmt.mysqlflexibleservers.models.PatchStrategy": null, + "azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance": null, + "azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType": null, + "azure.mgmt.mysqlflexibleservers.models.AdministratorType": null, + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState": null, + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState": null, + "azure.mgmt.mysqlflexibleservers.models.BackupType": null, + "azure.mgmt.mysqlflexibleservers.models.ProvisioningState": null, + "azure.mgmt.mysqlflexibleservers.models.ConfigurationSource": null, + "azure.mgmt.mysqlflexibleservers.models.IsReadOnly": null, + "azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart": null, + "azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig": null, + "azure.mgmt.mysqlflexibleservers.models.MaintenanceType": null, + "azure.mgmt.mysqlflexibleservers.models.MaintenanceState": null, + "azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState": null, + "azure.mgmt.mysqlflexibleservers.models.ObjectType": null, + "azure.mgmt.mysqlflexibleservers.models.AdministratorName": null, + "azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionName": null, + "azure.mgmt.mysqlflexibleservers.models.BackupFormat": null, + "azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault": null, + "azure.mgmt.mysqlflexibleservers.models.OperationStatus": null, + "azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.operations.Operations.list": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.Operations.list": null, + "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.list_by_resource_group": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.list_by_resource_group": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_create": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_create": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_detach_v_net": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_detach_v_net": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_failover": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_failover": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_reset_gtid": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_reset_gtid": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_restart": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_restart": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_start": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_start": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.begin_stop": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.begin_stop": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersOperations.validate_estimate_high_availability": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations.validate_estimate_high_availability": null, + "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations.list": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations.list": null, + "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.list": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.list": null, + "azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations.execute": null, + "azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.list": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.list": null, + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update_put": null, + "azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.begin_create": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.begin_create": null, + "azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations.validate_backup": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations.validate_backup": null, + "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.BackupsOperations.put": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations.put": null, + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.list": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.list": null, + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations.begin_create": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupOperations.begin_create": null, + "azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LongRunningBackupOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations.begin_batch_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations.begin_batch_update": null, + "azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations.begin_cutover_migration": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations.begin_cutover_migration": null, + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.list": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.list": null, + "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.read": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.read": null, + "azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations.begin_update": null, + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, + "azure.mgmt.mysqlflexibleservers.operations.PrivateEndpointConnectionsOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null, + "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations.get": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations.get": null, + "azure.mgmt.mysqlflexibleservers.operations.ReplicasOperations.list_by_server": null, + "azure.mgmt.mysqlflexibleservers.aio.operations.ReplicasOperations.list_by_server": null } } \ No newline at end of file diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__init__.py index 35aa45b31e42..e811f4d2e769 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/__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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest 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 ._client import MySQLManagementClient # type: ignore +from ._my_sql_management_client import MySQLManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_configuration.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_configuration.py index b0b453dec88b..36b661b8b272 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_configuration.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,18 +24,15 @@ class MySQLManagementClientConfiguration: # pylint: disable=too-many-instance-a Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential used to authenticate requests to the service. Required. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :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. Default value is - "2025-06-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: Api Version. Default value is "2025-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -43,7 +40,6 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -56,7 +52,6 @@ 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"]) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_client.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_my_sql_management_client.py similarity index 93% rename from sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_client.py rename to sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_my_sql_management_client.py index b170353b3c11..84d4d13b1aa9 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_client.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_my_sql_management_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,6 +17,7 @@ from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints +from . import models as _models from ._configuration import MySQLManagementClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( @@ -57,21 +58,45 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes Azure MySQL resources including servers, databases, firewall rules, VNET rules, log files and configurations with new business model. + :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations + :vartype get_private_dns_zone_suffix: + azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.mysqlflexibleservers.operations.Operations + :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations + operations + :vartype check_name_availability_without_location: + azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.mysqlflexibleservers.operations.ServersOperations + :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations + :vartype location_based_capabilities: + azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations + :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations + :vartype location_based_capability_set: + azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations + :ivar check_name_availability: CheckNameAvailabilityOperations operations + :vartype check_name_availability: + azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations + :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations + :vartype check_virtual_network_subnet_usage: + azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations + :ivar operation_progress: OperationProgressOperations operations + :vartype operation_progress: + azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: + azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations :ivar azure_ad_administrators: AzureADAdministratorsOperations operations :vartype azure_ad_administrators: azure.mgmt.mysqlflexibleservers.operations.AzureADAdministratorsOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.mysqlflexibleservers.operations.ServersOperations + :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations + operations + :vartype advanced_threat_protection_settings: + azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations :ivar backup_and_export: BackupAndExportOperations operations :vartype backup_and_export: azure.mgmt.mysqlflexibleservers.operations.BackupAndExportOperations - :ivar log_files: LogFilesOperations operations - :vartype log_files: azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations - :ivar servers_migration: ServersMigrationOperations operations - :vartype servers_migration: - azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations :ivar backups: BackupsOperations operations :vartype backups: azure.mgmt.mysqlflexibleservers.operations.BackupsOperations :ivar long_running_backups: LongRunningBackupsOperations operations @@ -82,17 +107,15 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes azure.mgmt.mysqlflexibleservers.operations.LongRunningBackupOperations :ivar configurations: ConfigurationsOperations operations :vartype configurations: azure.mgmt.mysqlflexibleservers.operations.ConfigurationsOperations + :ivar servers_migration: ServersMigrationOperations operations + :vartype servers_migration: + azure.mgmt.mysqlflexibleservers.operations.ServersMigrationOperations :ivar databases: DatabasesOperations operations :vartype databases: azure.mgmt.mysqlflexibleservers.operations.DatabasesOperations :ivar firewall_rules: FirewallRulesOperations operations :vartype firewall_rules: azure.mgmt.mysqlflexibleservers.operations.FirewallRulesOperations - :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations - operations - :vartype advanced_threat_protection_settings: - azure.mgmt.mysqlflexibleservers.operations.AdvancedThreatProtectionSettingsOperations - :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations - :vartype location_based_capability_set: - azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitySetOperations + :ivar log_files: LogFilesOperations operations + :vartype log_files: azure.mgmt.mysqlflexibleservers.operations.LogFilesOperations :ivar maintenances: MaintenancesOperations operations :vartype maintenances: azure.mgmt.mysqlflexibleservers.operations.MaintenancesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations @@ -101,42 +124,19 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.mysqlflexibleservers.operations.PrivateLinkResourcesOperations - :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations - :vartype location_based_capabilities: - azure.mgmt.mysqlflexibleservers.operations.LocationBasedCapabilitiesOperations - :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations - :vartype check_virtual_network_subnet_usage: - azure.mgmt.mysqlflexibleservers.operations.CheckVirtualNetworkSubnetUsageOperations - :ivar check_name_availability: CheckNameAvailabilityOperations operations - :vartype check_name_availability: - azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityOperations - :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations - operations - :vartype check_name_availability_without_location: - azure.mgmt.mysqlflexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations - :ivar operation_results: OperationResultsOperations operations - :vartype operation_results: - azure.mgmt.mysqlflexibleservers.operations.OperationResultsOperations - :ivar operation_progress: OperationProgressOperations operations - :vartype operation_progress: - azure.mgmt.mysqlflexibleservers.operations.OperationProgressOperations - :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations - :vartype get_private_dns_zone_suffix: - azure.mgmt.mysqlflexibleservers.operations.GetPrivateDnsZoneSuffixOperations :ivar replicas: ReplicasOperations operations :vartype replicas: azure.mgmt.mysqlflexibleservers.operations.ReplicasOperations - :param credential: Credential used to authenticate requests to the service. Required. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :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 None. + :param base_url: Service URL. 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. Default value is - "2025-06-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: Api Version. Default value is "2025-06-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. @@ -151,7 +151,6 @@ 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: @@ -160,7 +159,6 @@ def __init__( self._config = MySQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, - base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -184,76 +182,77 @@ 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, _endpoint), policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - self._serialize = Serializer() - self._deserialize = Deserializer() + 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.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.azure_ad_administrators = AzureADAdministratorsOperations( + self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( self._client, self._config, self._serialize, self._deserialize ) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.backup_and_export = BackupAndExportOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.servers_migration = ServersMigrationOperations( + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.location_based_capabilities = LocationBasedCapabilitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_running_backups = LongRunningBackupsOperations( + self.location_based_capability_set = LocationBasedCapabilitySetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_running_backup = LongRunningBackupOperations( + self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( + self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( self._client, self._config, self._serialize, self._deserialize ) - self.location_based_capability_set = LocationBasedCapabilitySetOperations( + self.operation_progress = OperationProgressOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.operation_results = OperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.azure_ad_administrators = AzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.location_based_capabilities = LocationBasedCapabilitiesOperations( + self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( + self.backup_and_export = BackupAndExportOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_name_availability = CheckNameAvailabilityOperations( + self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_running_backups = LongRunningBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( + self.long_running_backup = LongRunningBackupOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_results = OperationResultsOperations( + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers_migration = ServersMigrationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_progress = OperationProgressOperations( + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.replicas = ReplicasOperations(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 @@ -266,11 +265,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - 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) + request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/__init__.py index 8026245c2abc..0af9b28f6607 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py deleted file mode 100644 index 12926fa98dcf..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/model_base.py +++ /dev/null @@ -1,1237 +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) 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") - - -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" -) - - -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 - - -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) - - -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 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: - return self._data.__getitem__(key) - - def __setitem__(self, key: str, value: typing.Any) -> None: - 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: - 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): - 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: # pylint: disable=too-many-nested-blocks - if isinstance(args[0], ET.Element): - existed_attr_keys = [] - model_meta = getattr(self, "_xml", {}) - - 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 = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - if prop_meta.get("itemsName"): - xml_name = prop_meta.get("itemsName") - xml_ns = prop_meta.get("itemNs") - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = args[0].findall(xml_name) # pyright: ignore - if len(items) > 0: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) - continue - - # text element is primitive type - if prop_meta.get("text", False): - if args[0].text is not None: - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = args[0].find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) - - # rest thing is additional properties - for e in args[0]: - if e.tag not in existed_attr_keys: - dict_to_pass[e.tag] = _convert_element(e) - 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 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._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_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 = prop_meta.get("ns", model_meta.get("ns", None)) - 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 _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) - 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 for a in annotation.__args__ if a == type(None)): # pyright: ignore - if len(annotation.__args__) <= 2: # pyright: ignore - if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), 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 != type(None)] # 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 is None: - return value - if deserializer in [int, float, bool]: - return deserializer(value) - if isinstance(deserializer, CaseInsensitiveEnumMeta): - try: - return deserializer(value) - except ValueError: - # for unknown value, return raw value - return 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 DeserializationError: - _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 DeserializationError: - _LOGGER.warning( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - -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, - ): - 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._default = default - self._format = format - self._is_multipart_file_input = is_multipart_file_input - self._xml = xml if xml is not None else {} - - @property - def _class_type(self) -> typing.Any: - return getattr(self._type, "args", [None])[0] - - @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 - item = obj.get(self._rest_name) - if item is None: - return item - if self._is_model: - return item - return _deserialize(self._type, _serialize(item, self._format), rf=self) - - def __set__(self, obj: Model, value) -> None: - 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, -) -> typing.Any: - return _RestField( - name=name, - type=type, - visibility=visibility, - default=default, - format=format, - is_multipart_file_input=is_multipart_file_input, - xml=xml, - ) - - -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_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: - wrapped_element = _create_xml_element( - model_meta.get("name", o.__class__.__name__), - model_meta.get("prefix"), - model_meta.get("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} - - # if no ns for prop, use model's - 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): - xml_name = prop_meta.get("name", k) - if prop_meta.get("ns"): - ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore - xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore - # attribute should be primitive type - wrapped_element.set(xml_name, _get_primitive_type_value(v)) - 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 = [] - for k, v in o.items(): - result.append( - _get_wrapped_element( - v, - exclude_readonly, - { - "name": k, - "ns": parent_meta.get("ns") if parent_meta else None, - "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: - 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": parent_meta.get("itemsNs", parent_meta.get("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: - wrapped_element = _create_xml_element( - meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None - ) - 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 - - -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 _create_xml_element(tag, prefix=None, ns=None): - if prefix and ns: - ET.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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/serialization.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/serialization.py index 45a3e44e45cb..ff543ed937ff 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_utils/serialization.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_validation.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_validation.py deleted file mode 100644 index f5af3a4eb8a2..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/_validation.py +++ /dev/null @@ -1,66 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/__init__.py index d85e1983f06f..e557bb5173b5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest 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 ._client import MySQLManagementClient # type: ignore +from ._my_sql_management_client import MySQLManagementClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_configuration.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_configuration.py index b8e0b29c92f1..dc5195e1abd1 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_configuration.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,18 +24,15 @@ class MySQLManagementClientConfiguration: # pylint: disable=too-many-instance-a Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential used to authenticate requests to the service. Required. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :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. Default value is - "2025-06-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: Api Version. Default value is "2025-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -43,7 +40,6 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -56,7 +52,6 @@ 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"]) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_client.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_my_sql_management_client.py similarity index 94% rename from sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_client.py rename to sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_my_sql_management_client.py index b79cf67bd9ab..45031fc72a26 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_client.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/_my_sql_management_client.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -17,6 +17,7 @@ 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 MySQLManagementClientConfiguration from .operations import ( @@ -57,21 +58,45 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes Azure MySQL resources including servers, databases, firewall rules, VNET rules, log files and configurations with new business model. + :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations + :vartype get_private_dns_zone_suffix: + azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.mysqlflexibleservers.aio.operations.Operations + :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations + operations + :vartype check_name_availability_without_location: + azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations + :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations + :vartype location_based_capabilities: + azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations + :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations + :vartype location_based_capability_set: + azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations + :ivar check_name_availability: CheckNameAvailabilityOperations operations + :vartype check_name_availability: + azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations + :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations + :vartype check_virtual_network_subnet_usage: + azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations + :ivar operation_progress: OperationProgressOperations operations + :vartype operation_progress: + azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations + :ivar operation_results: OperationResultsOperations operations + :vartype operation_results: + azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations :ivar azure_ad_administrators: AzureADAdministratorsOperations operations :vartype azure_ad_administrators: azure.mgmt.mysqlflexibleservers.aio.operations.AzureADAdministratorsOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.mysqlflexibleservers.aio.operations.ServersOperations + :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations + operations + :vartype advanced_threat_protection_settings: + azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations :ivar backup_and_export: BackupAndExportOperations operations :vartype backup_and_export: azure.mgmt.mysqlflexibleservers.aio.operations.BackupAndExportOperations - :ivar log_files: LogFilesOperations operations - :vartype log_files: azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations - :ivar servers_migration: ServersMigrationOperations operations - :vartype servers_migration: - azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations :ivar backups: BackupsOperations operations :vartype backups: azure.mgmt.mysqlflexibleservers.aio.operations.BackupsOperations :ivar long_running_backups: LongRunningBackupsOperations operations @@ -83,17 +108,15 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar configurations: ConfigurationsOperations operations :vartype configurations: azure.mgmt.mysqlflexibleservers.aio.operations.ConfigurationsOperations + :ivar servers_migration: ServersMigrationOperations operations + :vartype servers_migration: + azure.mgmt.mysqlflexibleservers.aio.operations.ServersMigrationOperations :ivar databases: DatabasesOperations operations :vartype databases: azure.mgmt.mysqlflexibleservers.aio.operations.DatabasesOperations :ivar firewall_rules: FirewallRulesOperations operations :vartype firewall_rules: azure.mgmt.mysqlflexibleservers.aio.operations.FirewallRulesOperations - :ivar advanced_threat_protection_settings: AdvancedThreatProtectionSettingsOperations - operations - :vartype advanced_threat_protection_settings: - azure.mgmt.mysqlflexibleservers.aio.operations.AdvancedThreatProtectionSettingsOperations - :ivar location_based_capability_set: LocationBasedCapabilitySetOperations operations - :vartype location_based_capability_set: - azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitySetOperations + :ivar log_files: LogFilesOperations operations + :vartype log_files: azure.mgmt.mysqlflexibleservers.aio.operations.LogFilesOperations :ivar maintenances: MaintenancesOperations operations :vartype maintenances: azure.mgmt.mysqlflexibleservers.aio.operations.MaintenancesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations @@ -102,42 +125,19 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.mysqlflexibleservers.aio.operations.PrivateLinkResourcesOperations - :ivar location_based_capabilities: LocationBasedCapabilitiesOperations operations - :vartype location_based_capabilities: - azure.mgmt.mysqlflexibleservers.aio.operations.LocationBasedCapabilitiesOperations - :ivar check_virtual_network_subnet_usage: CheckVirtualNetworkSubnetUsageOperations operations - :vartype check_virtual_network_subnet_usage: - azure.mgmt.mysqlflexibleservers.aio.operations.CheckVirtualNetworkSubnetUsageOperations - :ivar check_name_availability: CheckNameAvailabilityOperations operations - :vartype check_name_availability: - azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityOperations - :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations - operations - :vartype check_name_availability_without_location: - azure.mgmt.mysqlflexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations - :ivar operation_results: OperationResultsOperations operations - :vartype operation_results: - azure.mgmt.mysqlflexibleservers.aio.operations.OperationResultsOperations - :ivar operation_progress: OperationProgressOperations operations - :vartype operation_progress: - azure.mgmt.mysqlflexibleservers.aio.operations.OperationProgressOperations - :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations - :vartype get_private_dns_zone_suffix: - azure.mgmt.mysqlflexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations :ivar replicas: ReplicasOperations operations :vartype replicas: azure.mgmt.mysqlflexibleservers.aio.operations.ReplicasOperations - :param credential: Credential used to authenticate requests to the service. Required. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :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 None. + :param base_url: Service URL. 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. Default value is - "2025-06-01-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: Api Version. Default value is "2025-06-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. @@ -152,7 +152,6 @@ 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: @@ -161,7 +160,6 @@ def __init__( self._config = MySQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, - base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -186,71 +184,72 @@ def __init__( self._config.http_logging_policy, ] self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, _endpoint), policies=_policies, **kwargs + base_url=cast(str, base_url), policies=_policies, **kwargs ) - self._serialize = Serializer() - self._deserialize = Deserializer() + 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.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.azure_ad_administrators = AzureADAdministratorsOperations( + self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( self._client, self._config, self._serialize, self._deserialize ) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.backup_and_export = BackupAndExportOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.servers_migration = ServersMigrationOperations( + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.location_based_capabilities = LocationBasedCapabilitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_running_backups = LongRunningBackupsOperations( + self.location_based_capability_set = LocationBasedCapabilitySetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_running_backup = LongRunningBackupOperations( + self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( + self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( self._client, self._config, self._serialize, self._deserialize ) - self.location_based_capability_set = LocationBasedCapabilitySetOperations( + self.operation_progress = OperationProgressOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.operation_results = OperationResultsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.azure_ad_administrators = AzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.location_based_capabilities = LocationBasedCapabilitiesOperations( + self.advanced_threat_protection_settings = AdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_virtual_network_subnet_usage = CheckVirtualNetworkSubnetUsageOperations( + self.backup_and_export = BackupAndExportOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_name_availability = CheckNameAvailabilityOperations( + self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_running_backups = LongRunningBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( + self.long_running_backup = LongRunningBackupOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_results = OperationResultsOperations( + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers_migration = ServersMigrationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation_progress = OperationProgressOperations( + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_files = LogFilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenances = MaintenancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) self.replicas = ReplicasOperations(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. @@ -258,7 +257,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 @@ -271,11 +270,7 @@ def send_request( """ request_copy = deepcopy(request) - 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) + request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/__init__.py index d833fa5e1131..f9cdf4c5b3fd 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/__init__.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,61 +13,61 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._get_private_dns_zone_suffix_operations import GetPrivateDnsZoneSuffixOperations # type: ignore from ._operations import Operations # type: ignore -from ._operations import AzureADAdministratorsOperations # type: ignore -from ._operations import ServersOperations # type: ignore -from ._operations import BackupAndExportOperations # type: ignore -from ._operations import LogFilesOperations # type: ignore -from ._operations import ServersMigrationOperations # type: ignore -from ._operations import BackupsOperations # type: ignore -from ._operations import LongRunningBackupsOperations # type: ignore -from ._operations import LongRunningBackupOperations # type: ignore -from ._operations import ConfigurationsOperations # type: ignore -from ._operations import DatabasesOperations # type: ignore -from ._operations import FirewallRulesOperations # type: ignore -from ._operations import AdvancedThreatProtectionSettingsOperations # type: ignore -from ._operations import LocationBasedCapabilitySetOperations # type: ignore -from ._operations import MaintenancesOperations # type: ignore -from ._operations import PrivateEndpointConnectionsOperations # type: ignore -from ._operations import PrivateLinkResourcesOperations # type: ignore -from ._operations import LocationBasedCapabilitiesOperations # type: ignore -from ._operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore -from ._operations import CheckNameAvailabilityOperations # type: ignore -from ._operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore -from ._operations import OperationResultsOperations # type: ignore -from ._operations import OperationProgressOperations # type: ignore -from ._operations import GetPrivateDnsZoneSuffixOperations # type: ignore -from ._operations import ReplicasOperations # type: ignore +from ._check_name_availability_without_location_operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore +from ._servers_operations import ServersOperations # type: ignore +from ._location_based_capabilities_operations import LocationBasedCapabilitiesOperations # type: ignore +from ._location_based_capability_set_operations import LocationBasedCapabilitySetOperations # type: ignore +from ._check_name_availability_operations import CheckNameAvailabilityOperations # type: ignore +from ._check_virtual_network_subnet_usage_operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore +from ._operation_progress_operations import OperationProgressOperations # type: ignore +from ._operation_results_operations import OperationResultsOperations # type: ignore +from ._azure_ad_administrators_operations import AzureADAdministratorsOperations # type: ignore +from ._advanced_threat_protection_settings_operations import AdvancedThreatProtectionSettingsOperations # type: ignore +from ._backup_and_export_operations import BackupAndExportOperations # type: ignore +from ._backups_operations import BackupsOperations # type: ignore +from ._long_running_backups_operations import LongRunningBackupsOperations # type: ignore +from ._long_running_backup_operations import LongRunningBackupOperations # type: ignore +from ._configurations_operations import ConfigurationsOperations # type: ignore +from ._servers_migration_operations import ServersMigrationOperations # type: ignore +from ._databases_operations import DatabasesOperations # type: ignore +from ._firewall_rules_operations import FirewallRulesOperations # type: ignore +from ._log_files_operations import LogFilesOperations # type: ignore +from ._maintenances_operations import MaintenancesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._replicas_operations import ReplicasOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "GetPrivateDnsZoneSuffixOperations", "Operations", - "AzureADAdministratorsOperations", + "CheckNameAvailabilityWithoutLocationOperations", "ServersOperations", + "LocationBasedCapabilitiesOperations", + "LocationBasedCapabilitySetOperations", + "CheckNameAvailabilityOperations", + "CheckVirtualNetworkSubnetUsageOperations", + "OperationProgressOperations", + "OperationResultsOperations", + "AzureADAdministratorsOperations", + "AdvancedThreatProtectionSettingsOperations", "BackupAndExportOperations", - "LogFilesOperations", - "ServersMigrationOperations", "BackupsOperations", "LongRunningBackupsOperations", "LongRunningBackupOperations", "ConfigurationsOperations", + "ServersMigrationOperations", "DatabasesOperations", "FirewallRulesOperations", - "AdvancedThreatProtectionSettingsOperations", - "LocationBasedCapabilitySetOperations", + "LogFilesOperations", "MaintenancesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", - "LocationBasedCapabilitiesOperations", - "CheckVirtualNetworkSubnetUsageOperations", - "CheckNameAvailabilityOperations", - "CheckNameAvailabilityWithoutLocationOperations", - "OperationResultsOperations", - "OperationProgressOperations", - "GetPrivateDnsZoneSuffixOperations", "ReplicasOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py new file mode 100644 index 000000000000..7bcfe6dc8063 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_advanced_threat_protection_settings_operations.py @@ -0,0 +1,678 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._advanced_threat_protection_settings_operations import ( + build_get_request, + build_list_request, + build_update_put_request, + build_update_request, +) +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AdvancedThreatProtection"]: + """Gets a list of 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 either AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvancedThreatProtectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AdvancedThreatProtectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.AdvancedThreatProtection: + """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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :return: AdvancedThreatProtection or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvancedThreatProtection] = 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvancedThreatProtection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_put_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, 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", self._config.api_version)) + 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, "AdvancedThreatProtection") + + _request = build_update_put_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, 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 == 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.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_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_put( + 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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is either a + AdvancedThreatProtection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AdvancedThreatProtection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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_put_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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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", self._config.api_version)) + 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, "AdvancedThreatProtectionForUpdate") + + _request = build_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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtectionForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate + :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is either a + AdvancedThreatProtectionForUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either AdvancedThreatProtection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + 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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py new file mode 100644 index 000000000000..82a01815bb33 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_azure_ad_administrators_operations.py @@ -0,0 +1,575 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._azure_ad_administrators_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_server_request, +) +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class AzureADAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.AzureADAdministrator"]: + """List all the AAD administrators in 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 + :return: An iterator like instance of either AzureADAdministrator or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) + 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, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> _models.AzureADAdministrator: + """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :return: AzureADAdministrator or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AzureADAdministrator] = 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureADAdministrator", 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.AzureADAdministrator, 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", self._config.api_version)) + 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, "AzureADAdministrator") + + _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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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.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, + administrator_name: Union[str, _models.AdministratorName], + parameters: _models.AzureADAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :keyword content_type: Body Parameter 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 AzureADAdministrator or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: IO[bytes] + :keyword content_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 AzureADAdministrator or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. Is + either a AzureADAdministrator type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AzureADAdministrator or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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("AzureADAdministrator", 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.AzureADAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AzureADAdministrator]( + 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", self._config.api_version)) + 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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_operations.py new file mode 100644 index 000000000000..7d7b2308fb84 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backup_and_export_operations.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._backup_and_export_operations import build_create_request, build_validate_backup_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class BackupAndExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`backup_and_export` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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.BackupAndExportRequest, 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", self._config.api_version)) + 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, "BackupAndExportRequest") + + _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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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( + self, + resource_group_name: str, + server_name: str, + parameters: _models.BackupAndExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest + :keyword content_type: Body Parameter 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 BackupAndExportResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: IO[bytes] + :keyword content_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 BackupAndExportResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupAndExportRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Is either a BackupAndExportRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupAndExportResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupAndExportResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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): + deserialized = self._deserialize("BackupAndExportResponse", 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.BackupAndExportResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupAndExportResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def validate_backup( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> _models.ValidateBackupResponse: + """Validates if backup can be performed for 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 + :return: ValidateBackupResponse or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) + + _request = build_validate_backup_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ValidateBackupResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py new file mode 100644 index 000000000000..3d0ad5e14d75 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_backups_operations.py @@ -0,0 +1,272 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._backups_operations import build_get_request, build_list_by_server_request, build_put_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class BackupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.ServerBackup"]: + """List all the backups 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 + :return: An iterator like instance of either ServerBackup or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerBackupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, backup_name: str, **kwargs: Any + ) -> _models.ServerBackup: + """List all the backups 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_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("ServerBackup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def put( + self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any + ) -> _models.ServerBackup: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_put_request( + resource_group_name=resource_group_name, + server_name=server_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("ServerBackup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py new file mode 100644 index 000000000000..35fee375a974 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_operations.py @@ -0,0 +1,177 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._check_name_availability_operations import build_execute_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class CheckNameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, + location_name: str, + name_availability_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def execute( + self, + location_name: str, + name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or + a IO[bytes] type. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") + + _request = build_execute_request( + location_name=location_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py new file mode 100644 index 000000000000..16341e2fa228 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_name_availability_without_location_operations.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._check_name_availability_without_location_operations import build_execute_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`check_name_availability_without_location` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def execute( + self, name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or + a IO[bytes] type. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") + + _request = build_execute_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("NameAvailability", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py new file mode 100644 index 000000000000..bc283d9e045b --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_check_virtual_network_subnet_usage_operations.py @@ -0,0 +1,171 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._check_virtual_network_subnet_usage_operations import build_execute_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class CheckVirtualNetworkSubnetUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + parameters: _models.VirtualNetworkSubnetUsageParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def execute( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :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: VirtualNetworkSubnetUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def execute( + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is either a VirtualNetworkSubnetUsageParameter type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or + IO[bytes] + :return: VirtualNetworkSubnetUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") + + _request = build_execute_request( + location_name=location_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualNetworkSubnetUsageResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py new file mode 100644 index 000000000000..3a36694b42ab --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_configurations_operations.py @@ -0,0 +1,884 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._configurations_operations import ( + build_batch_update_request, + build_create_or_update_request, + build_get_request, + build_list_by_server_request, + build_update_request, +) +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class ConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`configurations` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, + tags: Optional[str] = None, + keyword: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Configuration"]: + """List all the configurations in 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 tags: The tags of the server configuration. Default value is None. + :type tags: str + :param keyword: The keyword of the server configuration. Default value is None. + :type keyword: str + :param page: The page of the server configuration. Default value is None. + :type page: int + :param page_size: The pageSize of the server configuration. Default value is None. + :type page_size: int + :return: An iterator like instance of either Configuration or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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, + tags=tags, + keyword=keyword, + page=page, + page_size=page_size, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, configuration_name: str, **kwargs: Any + ) -> _models.Configuration: + """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :return: Configuration or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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("Configuration", 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, + configuration_name: str, + parameters: Union[_models.Configuration, 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", self._config.api_version)) + 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, "Configuration") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter 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 Configuration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is either a + Configuration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Configuration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, 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", self._config.api_version)) + 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, "Configuration") + + _request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter 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 Configuration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is either a + Configuration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Configuration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _batch_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, 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", self._config.api_version)) + 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, "ConfigurationListForBatchUpdate") + + _request = build_batch_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ConfigurationListForBatchUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate + :keyword content_type: Body Parameter 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 ConfigurationListResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 ConfigurationListResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Is either a + ConfigurationListForBatchUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either ConfigurationListResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._batch_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("ConfigurationListResult", 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.ConfigurationListResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ConfigurationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py new file mode 100644 index 000000000000..c5be56ff636e --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_databases_operations.py @@ -0,0 +1,557 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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_get_request, + build_list_by_server_request, +) +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Database"]: + """List all the databases in 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 + :return: An iterator like instance of either Database or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) + 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, **kwargs: Any + ) -> _models.Database: + """Gets information about 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: Database or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + 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("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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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.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, + 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 required parameters for creating or updating a database. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: 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 required parameters for creating or updating a database. Is either a + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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": "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 _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", self._config.api_version)) + 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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + 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 diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py new file mode 100644 index 000000000000..dd8e7566a8e3 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_firewall_rules_operations.py @@ -0,0 +1,560 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._firewall_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_server_request, +) +from .._configuration import MySQLManagementClientConfiguration + +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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.FirewallRule"]: + """List all the firewall rules in 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 + :return: An iterator like instance of either FirewallRule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) + 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, firewall_rule_name: str, **kwargs: Any + ) -> _models.FirewallRule: + """Gets information about a server 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 server firewall rule. Required. + :type firewall_rule_name: str + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FirewallRule", 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, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, 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", self._config.api_version)) + 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, "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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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 == 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.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, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of AsyncLROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_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 + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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: An instance of AsyncLROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or IO[bytes] + :return: An instance of AsyncLROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + firewall_rule_name=firewall_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("FirewallRule", 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.FirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, firewall_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", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = 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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, firewall_rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[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 server firewall rule. Required. + :type firewall_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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py new file mode 100644 index 000000000000..33e3387ff56c --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._get_private_dns_zone_suffix_operations import build_execute_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class GetPrivateDnsZoneSuffixOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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 execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: + """Get private DNS zone suffix in the cloud. + + :return: GetPrivateDnsZoneSuffixResponse or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) + + _request = build_execute_request( + 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("GetPrivateDnsZoneSuffixResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py new file mode 100644 index 000000000000..bb4758d07680 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capabilities_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._location_based_capabilities_operations import build_list_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class LocationBasedCapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.CapabilityProperties"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of either CapabilityProperties or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CapabilitiesListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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( + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CapabilitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py new file mode 100644 index 000000000000..f763588a5e25 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_location_based_capability_set_operations.py @@ -0,0 +1,196 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._location_based_capability_set_operations import build_get_request, build_list_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class LocationBasedCapabilitySetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`location_based_capability_set` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of either Capability or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CapabilitySetsList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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( + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CapabilitySetsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, capability_set_name: str = "default", **kwargs: Any) -> _models.Capability: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :param capability_set_name: Name of capability set. Default value is "default". + :type capability_set_name: str + :return: Capability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Capability] = kwargs.pop("cls", None) + + _request = build_get_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + capability_set_name=capability_set_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Capability", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py new file mode 100644 index 000000000000..9635b8c664e5 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_log_files_operations.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._log_files_operations import build_list_by_server_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class LogFilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`log_files` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: + """List all the server log files in 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 + :return: An iterator like instance of either LogFile or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LogFileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LogFileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_operations.py new file mode 100644 index 000000000000..32a817840792 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backup_operations.py @@ -0,0 +1,407 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._long_running_backup_operations import build_create_request, build_delete_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class LongRunningBackupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`long_running_backup` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ServerBackupV2") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + server_name=server_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, 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 == 201: + 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.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( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[_models.ServerBackupV2] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :keyword content_type: Body Parameter 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 ServerBackupV2 or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: IO[bytes] + :keyword content_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 ServerBackupV2 or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Is either a ServerBackupV2 type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ServerBackupV2 or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + 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("ServerBackupV2", 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.ServerBackupV2].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerBackupV2]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_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", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_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 [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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, backup_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete backup for a given server with specified backup 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 backup_name: The name of the backup. 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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py new file mode 100644 index 000000000000..4aed724c87fb --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_long_running_backups_operations.py @@ -0,0 +1,208 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._long_running_backups_operations import build_get_request, build_list_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class LongRunningBackupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`long_running_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerBackupV2"]: + """List all the backups 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 + :return: An iterator like instance of either ServerBackupV2 or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackupV2ListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerBackupV2ListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, backup_name: str, **kwargs: Any + ) -> _models.ServerBackupV2: + """Get backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackupV2 or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_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("ServerBackupV2", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py new file mode 100644 index 000000000000..e408e977e096 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_maintenances_operations.py @@ -0,0 +1,433 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._maintenances_operations import build_list_request, build_read_request, build_update_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class MaintenancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`maintenances` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Maintenance"]: + """List maintenances. + + :param resource_group_name: The name of the resource group. 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 either Maintenance or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MaintenanceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MaintenanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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 read( + self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any + ) -> _models.Maintenance: + """Read maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :return: Maintenance or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + + _request = build_read_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_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("Maintenance", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "MaintenanceUpdate") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + maintenance_name: str, + parameters: Optional[_models.MaintenanceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate + :keyword content_type: Body Parameter 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 Maintenance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: IO[bytes] + :keyword content_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 Maintenance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Is either a + MaintenanceUpdate type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Maintenance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, + maintenance_name=maintenance_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("Maintenance", 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.Maintenance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Maintenance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py new file mode 100644 index 000000000000..ffe58057466e --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_progress_operations.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._operation_progress_operations import build_get_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class OperationProgressOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationProgressResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) + + _request = build_get_request( + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationProgressResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py new file mode 100644 index 000000000000..83c6d8c032c9 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operation_results_operations.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._operation_results_operations import build_get_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class OperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusExtendedResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) + + _request = build_get_request( + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusExtendedResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py index d62daed157a0..f8cf9e654266 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_operations.py @@ -1,15 +1,12 @@ -# 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) Python Code Generator. +# Code generated by Microsoft (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 -import json -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Optional, TypeVar import urllib.parse from azure.core import AsyncPipelineClient @@ -20,95 +17,21 @@ 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 ..._validation import api_version_validation -from ...operations._operations import ( - build_advanced_threat_protection_settings_get_request, - build_advanced_threat_protection_settings_list_request, - build_advanced_threat_protection_settings_update_put_request, - build_advanced_threat_protection_settings_update_request, - build_azure_ad_administrators_create_or_update_request, - build_azure_ad_administrators_delete_request, - build_azure_ad_administrators_get_request, - build_azure_ad_administrators_list_by_server_request, - build_backup_and_export_create_request, - build_backup_and_export_validate_backup_request, - build_backups_get_request, - build_backups_list_by_server_request, - build_backups_put_request, - build_check_name_availability_execute_request, - build_check_name_availability_without_location_execute_request, - build_check_virtual_network_subnet_usage_execute_request, - build_configurations_batch_update_request, - build_configurations_create_or_update_request, - build_configurations_get_request, - build_configurations_list_by_server_request, - build_configurations_update_request, - build_databases_create_or_update_request, - build_databases_delete_request, - build_databases_get_request, - build_databases_list_by_server_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_get_private_dns_zone_suffix_execute_request, - build_location_based_capabilities_list_request, - build_location_based_capability_set_get_request, - build_location_based_capability_set_list_request, - build_log_files_list_by_server_request, - build_long_running_backup_create_request, - build_long_running_backup_delete_request, - build_long_running_backups_get_request, - build_long_running_backups_list_request, - build_maintenances_list_request, - build_maintenances_read_request, - build_maintenances_update_request, - build_operation_progress_get_request, - build_operation_results_get_request, - build_operations_list_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_replicas_list_by_server_request, - build_servers_create_request, - build_servers_delete_request, - build_servers_detach_v_net_request, - build_servers_failover_request, - build_servers_get_request, - build_servers_list_by_resource_group_request, - build_servers_list_request, - build_servers_migration_cutover_migration_request, - build_servers_reset_gtid_request, - build_servers_restart_request, - build_servers_start_request, - build_servers_stop_request, - build_servers_update_request, - build_servers_validate_estimate_high_availability_request, -) +from ...operations._operations import build_list_request from .._configuration import MySQLManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -JSON = MutableMapping[str, Any] List = list @@ -122,6 +45,8 @@ 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") @@ -133,596 +58,16 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """List the operations for the provider. - :return: An iterator like instance of Operation + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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 - - 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 AzureADAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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.AzureADAdministrator: - """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :return: AzureADAdministrator. The AzureADAdministrator is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) - - _request = build_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) - - _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() - else: - deserialized = _deserialize(_models.AzureADAdministrator, 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.AzureADAdministrator, 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_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) - - _stream = True - pipeline_response: PipelineResponse = await 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 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.AzureADAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns AzureADAdministrator. The - AzureADAdministrator is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: 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 AzureADAdministrator. The - AzureADAdministrator is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: IO[bytes] - :keyword content_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 AzureADAdministrator. The - AzureADAdministrator is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. Is - one of the following types: AzureADAdministrator, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or JSON or - IO[bytes] - :return: An instance of AsyncLROPoller that returns AzureADAdministrator. The - AzureADAdministrator is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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.AzureADAdministrator, 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.AzureADAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AzureADAdministrator]( - 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_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) - - _stream = True - pipeline_response: PipelineResponse = await self._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 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 an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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.AzureADAdministrator"]: - """List all the AAD administrators in 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 - :return: An iterator like instance of AzureADAdministrator - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - cls: ClsType[List[_models.AzureADAdministrator]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -735,20 +80,12 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - _request = build_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, + _request = build_list_request( + api_version=api_version, headers=_headers, params=_params, ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -763,8723 +100,16 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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.AzureADAdministrator], 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: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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.Server: - """Gets information about 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: Server. The Server is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Server, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_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_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) - - _stream = True - pipeline_response: PipelineResponse = await 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 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.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] - :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[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: 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.mysqlflexibleservers.models.Server] - :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[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.Server, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Is one of the - following types: Server, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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_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.ServerForUpdate, 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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 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.ServerForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate - :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.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.ServerForUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is one of the following - types: ServerForUpdate, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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) - - _stream = True - pipeline_response: PipelineResponse = await self._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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.iter_bytes() - - 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, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: - """List all the servers in a given 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 Server - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: - """List all the servers in a given subscription. - - :return: An iterator like instance of Server - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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 _failover_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_failover_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 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, **kwargs: Any) -> AsyncLROPoller[None]: - """Manual failover 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._failover_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 - - @overload - async def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: _models.HighAvailabilityValidationEstimation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.HighAvailabilityValidationEstimation, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is - one of the following types: HighAvailabilityValidationEstimation, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - or JSON or IO[bytes] - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~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.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) - - content_type = content_type or "application/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_validate_estimate_high_availability_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) - - _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() - else: - deserialized = _deserialize(_models.HighAvailabilityValidationEstimation, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _restart_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, 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_restart_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerRestartParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter - :keyword content_type: Body Parameter 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: IO[bytes] - :keyword content_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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts 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 required parameters for restarting a server. Is one of the following - types: ServerRestartParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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._restart_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 - - async def _start_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_start_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 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, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Starts 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._start_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 - - async def _stop_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_stop_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 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, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Stops 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._stop_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 - - async def _reset_gtid_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, 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_reset_gtid_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerGtidSetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter - :keyword content_type: Body Parameter 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: IO[bytes] - :keyword content_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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Is one of the - following types: ServerGtidSetParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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._reset_gtid_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 - - async def _detach_v_net_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, 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_detach_v_net_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerDetachVNetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter - :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: 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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Is one of the following - types: ServerDetachVNetParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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._detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = _deserialize(_models.Server, 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.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 - ) - - -class BackupAndExportOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`backup_and_export` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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.BackupAndExportRequest, 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_and_export_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 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.BackupAndExportRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: 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 BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: IO[bytes] - :keyword content_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 BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupAndExportRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Is one of the following types: BackupAndExportRequest, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or JSON or - IO[bytes] - :return: An instance of AsyncLROPoller that returns BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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.BackupAndExportResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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): - 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.BackupAndExportResponse, 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.BackupAndExportResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.BackupAndExportResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def validate_backup( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> _models.ValidateBackupResponse: - """Validates if backup can be performed for 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 - :return: ValidateBackupResponse. The ValidateBackupResponse is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) - - _request = build_backup_and_export_validate_backup_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) - - _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() - else: - deserialized = _deserialize(_models.ValidateBackupResponse, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class LogFilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`log_files` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: - """List all the server log files in 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 - :return: An iterator like instance of LogFile - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.LogFile]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_log_files_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.LogFile], 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 ServersMigrationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`servers_migration` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 _cutover_migration_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_migration_cutover_migration_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_cutover_migration( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible - 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 Server. The Server is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - 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._cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = _deserialize(_models.Server, 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.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 - ) - - -class BackupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, backup_name: str, **kwargs: Any - ) -> _models.ServerBackup: - """List all the backups 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup. The ServerBackup is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_backups_get_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _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() - else: - deserialized = _deserialize(_models.ServerBackup, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def put( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> _models.ServerBackup: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup. The ServerBackup is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_backups_put_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _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() - else: - deserialized = _deserialize(_models.ServerBackup, 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.ServerBackup"]: - """List all the backups 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 - :return: An iterator like instance of ServerBackup - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.ServerBackup]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_backups_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.ServerBackup], 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 LongRunningBackupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`long_running_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, backup_name: str, **kwargs: Any - ) -> _models.ServerBackupV2: - """Get backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackupV2. The ServerBackupV2 is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - - _request = build_long_running_backups_get_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _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() - else: - deserialized = _deserialize(_models.ServerBackupV2, 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, **kwargs: Any - ) -> AsyncItemPaged["_models.ServerBackupV2"]: - """List all the backups 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 - :return: An iterator like instance of ServerBackupV2 - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.ServerBackupV2]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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_running_backups_list_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.ServerBackupV2], 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 LongRunningBackupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`long_running_backup` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None - - _request = build_long_running_backup_create_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _stream = True - pipeline_response: PipelineResponse = await 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["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 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, - backup_name: str, - parameters: Optional[_models.ServerBackupV2] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns ServerBackupV2. The ServerBackupV2 is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: 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 ServerBackupV2. The ServerBackupV2 is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: IO[bytes] - :keyword content_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 ServerBackupV2. The ServerBackupV2 is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Is one of the following types: ServerBackupV2, JSON, IO[bytes] Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns ServerBackupV2. The ServerBackupV2 is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :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)) - content_type = content_type if parameters else None - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - 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.ServerBackupV2, 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.ServerBackupV2].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerBackupV2]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-06-01-preview", - params_added_on={ - "2025-06-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "server_name", - "backup_name", - ] - }, - api_versions_list=["2025-06-01-preview"], - ) - async def _delete_initial( - self, resource_group_name: str, server_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_running_backup_delete_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - @api_version_validation( - method_added_on="2025-06-01-preview", - params_added_on={ - "2025-06-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "server_name", - "backup_name", - ] - }, - api_versions_list=["2025-06-01-preview"], - ) - async def begin_delete( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete backup for a given server with specified backup 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 backup_name: The name of the backup. 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( - resource_group_name=resource_group_name, - server_name=server_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 - - -class ConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, configuration_name: str, **kwargs: Any - ) -> _models.Configuration: - """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :return: Configuration. The Configuration is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - - _request = build_configurations_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Configuration, 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, - configuration_name: str, - parameters: Union[_models.Configuration, 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_configurations_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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 = True - pipeline_response: PipelineResponse = await self._client._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 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: 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 Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is one of the - following types: Configuration, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :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.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, 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_configurations_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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 = True - pipeline_response: PipelineResponse = await self._client._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 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: 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 Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is one of the - following types: Configuration, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Configuration. The Configuration is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :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.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Configuration]( - 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, - *, - tags: Optional[str] = None, - keyword: Optional[str] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Configuration"]: - """List all the configurations in 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 - :keyword tags: The tags of the server configuration. Default value is None. - :paramtype tags: str - :keyword keyword: The keyword of the server configuration. Default value is None. - :paramtype keyword: str - :keyword page: The page of the server configuration. Default value is None. - :paramtype page: int - :keyword page_size: The pageSize of the server configuration. Default value is None. - :paramtype page_size: int - :return: An iterator like instance of Configuration - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Configuration]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_configurations_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - tags=tags, - keyword=keyword, - page=page, - page_size=page_size, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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.Configuration], 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 _batch_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, 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_configurations_batch_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ConfigurationListForBatchUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: 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 ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Is one of the - following types: ConfigurationListForBatchUpdate, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or - JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :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.ConfigurationListResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._batch_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.ConfigurationListResult, 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.ConfigurationListResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConfigurationListResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class DatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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.Database: - """Gets information about 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: Database. The Database is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - 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) - - _stream = True - pipeline_response: PipelineResponse = await 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 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 required parameters for creating or updating a database. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a database. Is one of the - following types: Database, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 _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) - - _stream = True - pipeline_response: PipelineResponse = await self._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 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 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 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 - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Database"]: - """List all the databases in 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 - :return: An iterator like instance of Database - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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 information about a server 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 server firewall rule. Required. - :type firewall_rule_name: str - :return: FirewallRule. The FirewallRule is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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) - - _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() - else: - deserialized = _deserialize(_models.FirewallRule, 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, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, 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_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) - - _stream = True - pipeline_response: PipelineResponse = await 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 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, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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 - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns FirewallRule. The FirewallRule is - compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :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.FirewallRule] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - firewall_rule_name=firewall_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.FirewallRule, 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.FirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, firewall_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_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 = True - pipeline_response: PipelineResponse = await self._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 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, firewall_rule_name: str, **kwargs: Any - ) -> AsyncLROPoller[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 server firewall rule. Required. - :type firewall_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, - firewall_rule_name=firewall_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.FirewallRule"]: - """List all the firewall rules in 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 - :return: An iterator like instance of FirewallRule - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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) - - -class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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.AdvancedThreatProtection: - """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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :return: AdvancedThreatProtection. The AdvancedThreatProtection is compatible with - MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_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) - - _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() - else: - deserialized = _deserialize(_models.AdvancedThreatProtection, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_put_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, 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_advanced_threat_protection_settings_update_put_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) - - _stream = True - pipeline_response: PipelineResponse = await 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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_put( - 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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: 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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_put( - 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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is one of the - following types: AdvancedThreatProtection, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or JSON or - IO[bytes] - :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :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.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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_put_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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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_advanced_threat_protection_settings_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) - - _stream = True - pipeline_response: PipelineResponse = await self._client._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 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, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtectionForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: 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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is one of the - following types: AdvancedThreatProtectionForUpdate, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or - JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :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.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - 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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.AdvancedThreatProtection"]: - """Gets a list of 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 AdvancedThreatProtection - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.AdvancedThreatProtection]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_advanced_threat_protection_settings_list_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.AdvancedThreatProtection], 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 LocationBasedCapabilitySetOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`location_based_capability_set` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, capability_set_name: str, **kwargs: Any) -> _models.Capability: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :param capability_set_name: Name of capability set. Required. - :type capability_set_name: str - :return: Capability. The Capability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Capability] = kwargs.pop("cls", None) - - _request = build_location_based_capability_set_get_request( - location_name=location_name, - capability_set_name=capability_set_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Capability, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Capability"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of Capability - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_location_based_capability_set_list_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.Capability], 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 MaintenancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`maintenances` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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 read( - self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any - ) -> _models.Maintenance: - """Read maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :return: Maintenance. The Maintenance is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - - _request = build_maintenances_read_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Maintenance, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None - - _request = build_maintenances_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_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 = True - pipeline_response: PipelineResponse = await self._client._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 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, - maintenance_name: str, - parameters: Optional[_models.MaintenanceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns Maintenance. The Maintenance is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: 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 Maintenance. The Maintenance is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: IO[bytes] - :keyword content_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 Maintenance. The Maintenance is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Is one of the - following types: MaintenanceUpdate, JSON, IO[bytes] Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or JSON or - IO[bytes] - :return: An instance of AsyncLROPoller that returns Maintenance. The Maintenance is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :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)) - content_type = content_type if parameters else None - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - maintenance_name=maintenance_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.Maintenance, 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.Maintenance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Maintenance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Maintenance"]: - """List maintenances. - - :param resource_group_name: The name of the resource group. 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 Maintenance - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Maintenance]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_maintenances_list_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.Maintenance], 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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with - MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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) - - _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() - 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) - - _stream = True - pipeline_response: PipelineResponse = await 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["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 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create 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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create 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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Is one of the following types: - PrivateEndpointConnection, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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) - - _stream = True - pipeline_response: PipelineResponse = await self._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 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 associated - with the Azure resource. 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_async - async def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnectionListResult: - """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: PrivateEndpointConnectionListResult. The PrivateEndpointConnectionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - _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) - - _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() - else: - deserialized = _deserialize(_models.PrivateEndpointConnectionListResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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 MySQL 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.mysqlflexibleservers.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) - - _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() - 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"]: - """Lists the private link resources for MySQL 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.mysqlflexibleservers.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 None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=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 LocationBasedCapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.CapabilityProperties"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of CapabilityProperties - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.CapabilityProperties]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_location_based_capabilities_list_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.CapabilityProperties], 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 CheckVirtualNetworkSubnetUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - parameters: _models.VirtualNetworkSubnetUsageParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def execute( - self, - location_name: str, - parameters: Union[_models.VirtualNetworkSubnetUsageParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Is one of the following types: - VirtualNetworkSubnetUsageParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or - JSON or IO[bytes] - :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~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.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_check_virtual_network_subnet_usage_execute_request( - location_name=location_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 = 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() - else: - deserialized = _deserialize(_models.VirtualNetworkSubnetUsageResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CheckNameAvailabilityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, - location_name: str, - name_availability_request: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, - location_name: str, - name_availability_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def execute( - self, - location_name: str, - name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Is one of the following types: - NameAvailabilityRequest, JSON, IO[bytes] Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_check_name_availability_execute_request( - location_name=location_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 = 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() - else: - deserialized = _deserialize(_models.NameAvailability, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`check_name_availability_without_location` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, name_availability_request: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def execute( - self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def execute( - self, name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Is one of the following types: - NameAvailabilityRequest, JSON, IO[bytes] Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_check_name_availability_without_location_execute_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) - - _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() - else: - deserialized = _deserialize(_models.NameAvailability, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class OperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationStatusExtendedResult. The OperationStatusExtendedResult is compatible with - MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) - - _request = build_operation_results_get_request( - 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) - - _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() - else: - deserialized = _deserialize(_models.OperationStatusExtendedResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class OperationProgressOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationProgressResult. The OperationProgressResult is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) - - _request = build_operation_progress_get_request( - 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) - - _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() - else: - deserialized = _deserialize(_models.OperationProgressResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class GetPrivateDnsZoneSuffixOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(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 execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: - """Get private DNS zone suffix in the cloud. - - :return: GetPrivateDnsZoneSuffixResponse. The GetPrivateDnsZoneSuffixResponse is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) - - _request = build_get_private_dns_zone_suffix_execute_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) - - _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() - else: - deserialized = _deserialize(_models.GetPrivateDnsZoneSuffixResponse, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class ReplicasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s - :attr:`replicas` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Server"]: - """List all the replicas 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 - :return: An iterator like instance of Server - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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_replicas_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) - + _request.url = self._client.format_url(_request.url) + _request.method = "GET" return _request async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -9492,9 +122,9 @@ 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) - error = _failsafe_deserialize( + error = self._deserialize.failsafe_deserialize( _models.ErrorResponse, - response, + pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..e592afb55bc1 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,536 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_server_request, +) +from .._configuration import MySQLManagementClientConfiguration + +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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, **kwargs: Any + ) -> _models.PrivateEndpointConnectionListResult: + """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: PrivateEndpointConnectionListResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + _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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_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("PrivateEndpointConnectionListResult", 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, 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, 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", self._config.api_version)) + 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, 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 == 201: + 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.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, + 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create 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.mysqlflexibleservers.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. The 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Is either a PrivateEndpointConnection type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, 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.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", self._config.api_version)) + 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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, 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 associated + with the Azure resource. 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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..6c6f669a8148 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,178 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._private_link_resources_operations import build_get_request, build_list_by_server_request +from .._configuration import MySQLManagementClientConfiguration + +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.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Lists the private link resources for MySQL 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: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("PrivateLinkResourceListResult", 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, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource for MySQL 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 or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py new file mode 100644 index 000000000000..90a042e79e51 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_replicas_operations.py @@ -0,0 +1,142 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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._replicas_operations import build_list_by_server_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`replicas` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Server"]: + """List all the replicas 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 + :return: An iterator like instance of either Server or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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_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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py new file mode 100644 index 000000000000..96953850489c --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_migration_operations.py @@ -0,0 +1,182 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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._servers_migration_operations import build_cutover_migration_request +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class ServersMigrationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'s + :attr:`servers_migration` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 _cutover_migration_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", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_cutover_migration( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible + 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 either Server or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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._cutover_migration_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("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, 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.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 + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py new file mode 100644 index 000000000000..1fad026f5398 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/aio/operations/_servers_operations.py @@ -0,0 +1,1903 @@ +# 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 +import urllib.parse + +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_create_request, + build_delete_request, + build_detach_v_net_request, + build_failover_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_reset_gtid_request, + build_restart_request, + build_start_request, + build_stop_request, + build_update_request, + build_validate_estimate_high_availability_request, +) +from .._configuration import MySQLManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class ServersOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.aio.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Server"]: + """List all the servers in a given subscription. + + :return: An iterator like instance of either Server or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: + """List all the servers in a given 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 either Server or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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, **kwargs: Any) -> _models.Server: + """Gets information about 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: Server or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + 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_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", self._config.api_version)) + 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_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 == 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.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( + self, + resource_group_name: str, + server_name: str, + parameters: _models.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] + :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[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Is either a + Server type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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): + 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, 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.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.ServerForUpdate, 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", self._config.api_version)) + 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, "ServerForUpdate") + + _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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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.ServerForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate + :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.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.ServerForUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is either a ServerForUpdate + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("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, 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.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", self._config.api_version)) + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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. 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + 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, 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[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 _detach_v_net_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, 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", self._config.api_version)) + 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, "ServerDetachVNetParameter") + + _request = build_detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerDetachVNetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter + :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Is either a + ServerDetachVNetParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._detach_v_net_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, 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.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 _failover_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", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_failover(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Manual failover 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._failover_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, 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 _reset_gtid_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, 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", self._config.api_version)) + 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, "ServerGtidSetParameter") + + _request = build_reset_gtid_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerGtidSetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter + :keyword content_type: Body Parameter 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: IO[bytes] + :keyword content_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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Is either a + ServerGtidSetParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reset_gtid_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, 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[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 _restart_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, 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", self._config.api_version)) + 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, "ServerRestartParameter") + + _request = build_restart_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerRestartParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter + :keyword content_type: Body Parameter 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: IO[bytes] + :keyword content_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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts 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 required parameters for restarting a server. Is either a + ServerRestartParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restart_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, 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 _start_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", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Starts 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_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, 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 _stop_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", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_stop_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Stops 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._stop_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, 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 + + @overload + async def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: _models.HighAvailabilityValidationEstimation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.HighAvailabilityValidationEstimation, IO[bytes]], + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is + either a HighAvailabilityValidationEstimation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + or IO[bytes] + :return: HighAvailabilityValidationEstimation or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "HighAvailabilityValidationEstimation") + + _request = build_validate_estimate_high_availability_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("HighAvailabilityValidationEstimation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__init__.py index dc2040884f1f..a15bffbdcdd1 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/__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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,40 +13,37 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models import ( # type: ignore - AdministratorProperties, +from ._models_py3 import ( # type: ignore + AdministratorListResult, AdvancedThreatProtection, AdvancedThreatProtectionForUpdate, - AdvancedThreatProtectionProperties, - AdvancedThreatProtectionUpdateProperties, + AdvancedThreatProtectionListResult, AzureADAdministrator, Backup, BackupAndExportRequest, BackupAndExportResponse, - BackupAndExportResponseProperties, BackupAndExportResponseType, BackupRequestBase, BackupSettings, BackupStoreDetails, + CapabilitiesListResult, Capability, CapabilityProperties, - CapabilityPropertiesV2, + CapabilitySetsList, Configuration, ConfigurationForBatchUpdate, - ConfigurationForBatchUpdateProperties, ConfigurationListForBatchUpdate, ConfigurationListResult, - ConfigurationProperties, DataEncryption, Database, - DatabaseProperties, + DatabaseListResult, DelegatedSubnetUsage, ErrorAdditionalInfo, ErrorDetail, ErrorResponse, FeatureProperty, FirewallRule, - FirewallRuleProperties, + FirewallRuleListResult, FullBackupStoreDetails, GetPrivateDnsZoneSuffixResponse, HighAvailability, @@ -54,11 +51,10 @@ ImportFromStorageResponseType, ImportSourceProperties, LogFile, - LogFileProperties, + LogFileListResult, Maintenance, + MaintenanceListResult, MaintenancePolicy, - MaintenanceProperties, - MaintenancePropertiesForUpdate, MaintenanceUpdate, MaintenanceWindow, MySQLServerIdentity, @@ -68,6 +64,7 @@ Network, Operation, OperationDisplay, + OperationListResult, OperationProgressResponseType, OperationProgressResult, OperationStatusExtendedResult, @@ -75,24 +72,22 @@ PrivateEndpoint, PrivateEndpointConnection, PrivateEndpointConnectionListResult, - PrivateEndpointConnectionProperties, PrivateLinkResource, - PrivateLinkResourceProperties, + PrivateLinkResourceListResult, PrivateLinkServiceConnectionState, ProxyResource, Resource, Server, ServerBackup, - ServerBackupProperties, - ServerBackupPropertiesV2, + ServerBackupListResult, ServerBackupV2, + ServerBackupV2ListResult, ServerDetachVNetParameter, ServerEditionCapability, ServerEditionCapabilityV2, ServerForUpdate, ServerGtidSetParameter, - ServerProperties, - ServerPropertiesForUpdate, + ServerListResult, ServerRestartParameter, ServerVersionCapability, ServerVersionCapabilityV2, @@ -104,12 +99,11 @@ TrackedResource, UserAssignedIdentity, ValidateBackupResponse, - ValidateBackupResponseProperties, VirtualNetworkSubnetUsageParameter, VirtualNetworkSubnetUsageResult, ) -from ._enums import ( # type: ignore +from ._my_sql_management_client_enums import ( # type: ignore AdministratorName, AdministratorType, AdvancedThreatProtectionName, @@ -153,39 +147,36 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AdministratorProperties", + "AdministratorListResult", "AdvancedThreatProtection", "AdvancedThreatProtectionForUpdate", - "AdvancedThreatProtectionProperties", - "AdvancedThreatProtectionUpdateProperties", + "AdvancedThreatProtectionListResult", "AzureADAdministrator", "Backup", "BackupAndExportRequest", "BackupAndExportResponse", - "BackupAndExportResponseProperties", "BackupAndExportResponseType", "BackupRequestBase", "BackupSettings", "BackupStoreDetails", + "CapabilitiesListResult", "Capability", "CapabilityProperties", - "CapabilityPropertiesV2", + "CapabilitySetsList", "Configuration", "ConfigurationForBatchUpdate", - "ConfigurationForBatchUpdateProperties", "ConfigurationListForBatchUpdate", "ConfigurationListResult", - "ConfigurationProperties", "DataEncryption", "Database", - "DatabaseProperties", + "DatabaseListResult", "DelegatedSubnetUsage", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "FeatureProperty", "FirewallRule", - "FirewallRuleProperties", + "FirewallRuleListResult", "FullBackupStoreDetails", "GetPrivateDnsZoneSuffixResponse", "HighAvailability", @@ -193,11 +184,10 @@ "ImportFromStorageResponseType", "ImportSourceProperties", "LogFile", - "LogFileProperties", + "LogFileListResult", "Maintenance", + "MaintenanceListResult", "MaintenancePolicy", - "MaintenanceProperties", - "MaintenancePropertiesForUpdate", "MaintenanceUpdate", "MaintenanceWindow", "MySQLServerIdentity", @@ -207,6 +197,7 @@ "Network", "Operation", "OperationDisplay", + "OperationListResult", "OperationProgressResponseType", "OperationProgressResult", "OperationStatusExtendedResult", @@ -214,24 +205,22 @@ "PrivateEndpoint", "PrivateEndpointConnection", "PrivateEndpointConnectionListResult", - "PrivateEndpointConnectionProperties", "PrivateLinkResource", - "PrivateLinkResourceProperties", + "PrivateLinkResourceListResult", "PrivateLinkServiceConnectionState", "ProxyResource", "Resource", "Server", "ServerBackup", - "ServerBackupProperties", - "ServerBackupPropertiesV2", + "ServerBackupListResult", "ServerBackupV2", + "ServerBackupV2ListResult", "ServerDetachVNetParameter", "ServerEditionCapability", "ServerEditionCapabilityV2", "ServerForUpdate", "ServerGtidSetParameter", - "ServerProperties", - "ServerPropertiesForUpdate", + "ServerListResult", "ServerRestartParameter", "ServerVersionCapability", "ServerVersionCapabilityV2", @@ -243,7 +232,6 @@ "TrackedResource", "UserAssignedIdentity", "ValidateBackupResponse", - "ValidateBackupResponseProperties", "VirtualNetworkSubnetUsageParameter", "VirtualNetworkSubnetUsageResult", "AdministratorName", diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py deleted file mode 100644 index 449aabbd4343..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models.py +++ /dev/null @@ -1,4289 +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) 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, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload - -from .._utils.model_base import Model as _Model, rest_discriminator, rest_field -from ._enums import ObjectType - -if TYPE_CHECKING: - from .. import models as _models - - -class AdministratorProperties(_Model): - """The properties of an administrator. - - :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" - :vartype administrator_type: str or ~azure.mgmt.mysqlflexibleservers.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 identity_resource_id: The resource id of the identity used for AAD Authentication. - :vartype identity_resource_id: str - """ - - administrator_type: Optional[Union[str, "_models.AdministratorType"]] = rest_field( - name="administratorType", visibility=["read", "create", "update", "delete", "query"] - ) - """Type of the sever administrator. \"ActiveDirectory\"""" - 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.""" - identity_resource_id: Optional[str] = rest_field( - name="identityResourceId", visibility=["read", "create", "update", "delete", "query"] - ) - """The resource id of the identity used for AAD Authentication.""" - - @overload - def __init__( - self, - *, - administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, - login: Optional[str] = None, - sid: Optional[str] = None, - tenant_id: Optional[str] = None, - identity_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 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.mysqlflexibleservers.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.mysqlflexibleservers.models.SystemData - """ - - -class AdvancedThreatProtection(ProxyResource): - """A server's 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.mysqlflexibleservers.models.SystemData - :ivar properties: Resource properties. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProperties - """ - - properties: Optional["_models.AdvancedThreatProtectionProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Resource properties.""" - - __flattened_items = ["creation_time", "state", "provisioning_state"] - - @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 AdvancedThreatProtectionForUpdate(_Model): - """Parameters allowed to update advanced threat protection for a server. - - :ivar properties: Resource update properties. - :vartype properties: - ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionUpdateProperties - """ - - properties: Optional["_models.AdvancedThreatProtectionUpdateProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Resource update properties.""" - - __flattened_items = ["state"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.AdvancedThreatProtectionUpdateProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 AdvancedThreatProtectionProperties(_Model): - """Properties of an Advanced Threat Protection setting. - - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - :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: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState - :ivar provisioning_state: Provisioning state of the Threat Protection. Known values are: - "Succeeded", "Updating", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState - """ - - creation_time: Optional[datetime.datetime] = rest_field(name="creationTime", visibility=["read"], format="rfc3339") - """Specifies the UTC creation time of the policy.""" - state: Optional[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. Known values are: - \"Enabled\" and \"Disabled\".""" - provisioning_state: Optional[Union[str, "_models.AdvancedThreatProtectionProvisioningState"]] = rest_field( - name="provisioningState", visibility=["read"] - ) - """Provisioning state of the Threat Protection. Known values are: \"Succeeded\", \"Updating\", - \"Canceled\", and \"Failed\".""" - - @overload - def __init__( - self, - *, - state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 AdvancedThreatProtectionUpdateProperties(_Model): - """Properties of Advanced Threat Protection that can be updated. - - :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: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState - """ - - 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: - \"Enabled\" and \"Disabled\".""" - - @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 AzureADAdministrator(ProxyResource): - """Represents a 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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of an administrator. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.AdministratorProperties - """ - - properties: Optional["_models.AdministratorProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of an administrator.""" - - __flattened_items = ["administrator_type", "login", "sid", "tenant_id", "identity_resource_id"] - - @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 Backup(_Model): - """Storage Profile properties of a server. - - :ivar backup_retention_days: Backup retention days for the server. - :vartype backup_retention_days: int - :ivar backup_interval_hours: Backup interval hours for the server. - :vartype backup_interval_hours: int - :ivar geo_redundant_backup: Whether or not geo redundant backup is enabled. Known values are: - "Enabled" and "Disabled". - :vartype geo_redundant_backup: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar earliest_restore_date: Earliest restore point creation time (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - """ - - backup_retention_days: Optional[int] = rest_field( - name="backupRetentionDays", visibility=["read", "create", "update", "delete", "query"] - ) - """Backup retention days for the server.""" - backup_interval_hours: Optional[int] = rest_field( - name="backupIntervalHours", visibility=["read", "create", "update", "delete", "query"] - ) - """Backup interval hours for the server.""" - geo_redundant_backup: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( - name="geoRedundantBackup", visibility=["read", "create", "update", "delete", "query"] - ) - """Whether or not geo redundant backup is enabled. Known values are: \"Enabled\" and \"Disabled\".""" - earliest_restore_date: Optional[datetime.datetime] = rest_field( - name="earliestRestoreDate", visibility=["read"], format="rfc3339" - ) - """Earliest restore point creation time (ISO8601 format).""" - - @overload - def __init__( - self, - *, - backup_retention_days: Optional[int] = None, - backup_interval_hours: Optional[int] = None, - geo_redundant_backup: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 BackupRequestBase(_Model): - """BackupRequestBase is the base for all backup request. - - :ivar backup_settings: Backup Settings. Required. - :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings - """ - - backup_settings: "_models.BackupSettings" = rest_field( - name="backupSettings", visibility=["read", "create", "update", "delete", "query"] - ) - """Backup Settings. Required.""" - - @overload - def __init__( - self, - *, - backup_settings: "_models.BackupSettings", - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 BackupAndExportRequest(BackupRequestBase): - """BackupAndExport API Request. - - :ivar backup_settings: Backup Settings. Required. - :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings - :ivar target_details: Backup Target Store Details. Required. - :vartype target_details: ~azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails - """ - - target_details: "_models.BackupStoreDetails" = rest_field( - name="targetDetails", visibility=["read", "create", "update", "delete", "query"] - ) - """Backup Target Store Details. Required.""" - - @overload - def __init__( - self, - *, - backup_settings: "_models.BackupSettings", - target_details: "_models.BackupStoreDetails", - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 BackupAndExportResponse(ProxyResource): - """Represents BackupAndExportAPI Response. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: 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.mysqlflexibleservers.models.SystemData - :ivar properties: The resource-specific properties for this resource. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponseProperties - :ivar error: The error object. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :ivar name: The name of the backup and export response. Required. - :vartype name: str - :ivar status: The operation status. Known values are: "Pending", "InProgress", "Succeeded", - "Failed", "CancelInProgress", and "Canceled". - :vartype status: str or ~azure.mgmt.mysqlflexibleservers.models.OperationStatus - :ivar start_time: Start time. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: Operation progress (0-100). - :vartype percent_complete: float - """ - - properties: Optional["_models.BackupAndExportResponseProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The resource-specific properties for this resource.""" - error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The error object.""" - name: str = rest_field(visibility=["read"]) - """The name of the backup and export response. Required.""" - status: Optional[Union[str, "_models.OperationStatus"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The operation status. Known values are: \"Pending\", \"InProgress\", \"Succeeded\", \"Failed\", - \"CancelInProgress\", and \"Canceled\".""" - start_time: Optional[datetime.datetime] = rest_field( - name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """Start time.""" - end_time: Optional[datetime.datetime] = rest_field( - name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """End time.""" - percent_complete: Optional[float] = rest_field( - name="percentComplete", visibility=["read", "create", "update", "delete", "query"] - ) - """Operation progress (0-100).""" - - __flattened_items = ["datasource_size_in_bytes", "data_transferred_in_bytes", "backup_metadata"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.BackupAndExportResponseProperties"] = None, - error: Optional["_models.ErrorDetail"] = None, - status: Optional[Union[str, "_models.OperationStatus"]] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - percent_complete: 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: - _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 BackupAndExportResponseProperties(_Model): - """BackupAndExport Response Properties. - - :ivar datasource_size_in_bytes: Size of datasource in bytes. - :vartype datasource_size_in_bytes: int - :ivar data_transferred_in_bytes: Data transferred in bytes. - :vartype data_transferred_in_bytes: int - :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in - key-value pairs. - :vartype backup_metadata: str - """ - - datasource_size_in_bytes: Optional[int] = rest_field( - name="datasourceSizeInBytes", visibility=["read", "create", "update", "delete", "query"] - ) - """Size of datasource in bytes.""" - data_transferred_in_bytes: Optional[int] = rest_field( - name="dataTransferredInBytes", visibility=["read", "create", "update", "delete", "query"] - ) - """Data transferred in bytes.""" - backup_metadata: Optional[str] = rest_field( - name="backupMetadata", visibility=["read", "create", "update", "delete", "query"] - ) - """Metadata related to backup to be stored for restoring resource in key-value pairs.""" - - @overload - def __init__( - self, - *, - datasource_size_in_bytes: Optional[int] = None, - data_transferred_in_bytes: Optional[int] = None, - backup_metadata: 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 OperationProgressResponseType(_Model): - """Represents the response properties specific to the operation. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - BackupAndExportResponseType, ImportFromStorageResponseType - - :ivar object_type: Identifies the type of source operation. Required. Known values are: - "BackupAndExportResponse" and "ImportFromStorageResponse". - :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType - """ - - __mapping__: dict[str, _Model] = {} - object_type: str = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) - """Identifies the type of source operation. Required. Known values are: - \"BackupAndExportResponse\" and \"ImportFromStorageResponse\".""" - - @overload - def __init__( - self, - *, - object_type: 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 BackupAndExportResponseType(OperationProgressResponseType, discriminator="BackupAndExportResponse"): - """BackupAndExport Response Properties. - - :ivar datasource_size_in_bytes: Size of datasource in bytes. - :vartype datasource_size_in_bytes: int - :ivar data_transferred_in_bytes: Data transferred in bytes. - :vartype data_transferred_in_bytes: int - :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in - key-value pairs. - :vartype backup_metadata: str - :ivar object_type: Identifies the type of source operation. Required. - :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.BACKUP_AND_EXPORT_RESPONSE - """ - - datasource_size_in_bytes: Optional[int] = rest_field( - name="datasourceSizeInBytes", visibility=["read", "create", "update", "delete", "query"] - ) - """Size of datasource in bytes.""" - data_transferred_in_bytes: Optional[int] = rest_field( - name="dataTransferredInBytes", visibility=["read", "create", "update", "delete", "query"] - ) - """Data transferred in bytes.""" - backup_metadata: Optional[str] = rest_field( - name="backupMetadata", visibility=["read", "create", "update", "delete", "query"] - ) - """Metadata related to backup to be stored for restoring resource in key-value pairs.""" - object_type: Literal[ObjectType.BACKUP_AND_EXPORT_RESPONSE] = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Identifies the type of source operation. Required.""" - - @overload - def __init__( - self, - *, - datasource_size_in_bytes: Optional[int] = None, - data_transferred_in_bytes: Optional[int] = None, - backup_metadata: 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) - self.object_type = ObjectType.BACKUP_AND_EXPORT_RESPONSE # type: ignore - - -class BackupSettings(_Model): - """Backup Settings. - - :ivar backup_name: The name of the backup. Required. - :vartype backup_name: str - :ivar backup_format: Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT - USE). Known values are: "CollatedFormat" and "Raw". - :vartype backup_format: str or ~azure.mgmt.mysqlflexibleservers.models.BackupFormat - """ - - backup_name: str = rest_field(name="backupName", visibility=["read", "create", "update", "delete", "query"]) - """The name of the backup. Required.""" - backup_format: Optional[Union[str, "_models.BackupFormat"]] = rest_field( - name="backupFormat", visibility=["read", "create", "update", "delete", "query"] - ) - """Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT USE). Known values - are: \"CollatedFormat\" and \"Raw\".""" - - @overload - def __init__( - self, - *, - backup_name: str, - backup_format: Optional[Union[str, "_models.BackupFormat"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 BackupStoreDetails(_Model): - """Details about the target where the backup content will be stored. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - FullBackupStoreDetails - - :ivar object_type: Type of the specific object - used for deserializing. Required. Default - value is None. - :vartype object_type: str - """ - - __mapping__: dict[str, _Model] = {} - object_type: str = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) - """Type of the specific object - used for deserializing. Required. Default value is None.""" - - @overload - def __init__( - self, - *, - object_type: 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 Capability(ProxyResource): - """Represents a location capability 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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a location capability set. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.CapabilityPropertiesV2 - """ - - properties: Optional["_models.CapabilityPropertiesV2"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a location capability set.""" - - __flattened_items = [ - "supported_geo_backup_regions", - "supported_flexible_server_editions", - "supported_server_versions", - "supported_features", - ] - - @overload - def __init__( - self, - *, - properties: Optional["_models.CapabilityPropertiesV2"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 CapabilityProperties(_Model): - """Location capabilities. - - :ivar zone: zone name. - :vartype zone: str - :ivar supported_ha_mode: Supported high availability mode. - :vartype supported_ha_mode: list[str] - :ivar supported_geo_backup_regions: supported geo backup regions. - :vartype supported_geo_backup_regions: list[str] - :ivar supported_flexible_server_editions: A list of supported flexible server editions. - :vartype supported_flexible_server_editions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability] - """ - - zone: Optional[str] = rest_field(visibility=["read"]) - """zone name.""" - supported_ha_mode: Optional[list[str]] = rest_field(name="supportedHAMode", visibility=["read"]) - """Supported high availability mode.""" - supported_geo_backup_regions: Optional[list[str]] = rest_field( - name="supportedGeoBackupRegions", visibility=["read"] - ) - """supported geo backup regions.""" - supported_flexible_server_editions: Optional[list["_models.ServerEditionCapability"]] = rest_field( - name="supportedFlexibleServerEditions", visibility=["read"] - ) - """A list of supported flexible server editions.""" - - -class CapabilityPropertiesV2(_Model): - """Location capability. - - :ivar supported_geo_backup_regions: supported geo backup regions. - :vartype supported_geo_backup_regions: list[str] - :ivar supported_flexible_server_editions: A list of supported flexible server editions. - :vartype supported_flexible_server_editions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2] - :ivar supported_server_versions: A list of supported server versions. - :vartype supported_server_versions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2] - :ivar supported_features: A list of supported features. - :vartype supported_features: list[~azure.mgmt.mysqlflexibleservers.models.FeatureProperty] - """ - - supported_geo_backup_regions: Optional[list[str]] = rest_field( - name="supportedGeoBackupRegions", visibility=["read"] - ) - """supported geo backup regions.""" - supported_flexible_server_editions: Optional[list["_models.ServerEditionCapabilityV2"]] = rest_field( - name="supportedFlexibleServerEditions", visibility=["read"] - ) - """A list of supported flexible server editions.""" - supported_server_versions: Optional[list["_models.ServerVersionCapabilityV2"]] = rest_field( - name="supportedServerVersions", visibility=["read"] - ) - """A list of supported server versions.""" - supported_features: Optional[list["_models.FeatureProperty"]] = rest_field( - name="supportedFeatures", visibility=["read"] - ) - """A list of supported features.""" - - -class Configuration(ProxyResource): - """Represents a Configuration. - - :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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a configuration. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationProperties - """ - - properties: Optional["_models.ConfigurationProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a configuration.""" - - __flattened_items = [ - "value", - "current_value", - "description", - "documentation_link", - "default_value", - "data_type", - "allowed_values", - "source", - "is_read_only", - "is_config_pending_restart", - "is_dynamic_config", - ] - - @overload - def __init__( - self, - *, - properties: Optional["_models.ConfigurationProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ConfigurationForBatchUpdate(_Model): - """Represents a Configuration. - - :ivar name: Name of the configuration. - :vartype name: str - :ivar properties: The properties can be updated for a configuration. - :vartype properties: - ~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdateProperties - """ - - name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Name of the configuration.""" - properties: Optional["_models.ConfigurationForBatchUpdateProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties can be updated for a configuration.""" - - __flattened_items = ["value", "source"] - - @overload - def __init__( - self, - *, - name: Optional[str] = None, - properties: Optional["_models.ConfigurationForBatchUpdateProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ConfigurationForBatchUpdateProperties(_Model): - """The properties can be updated for a configuration. - - :ivar value: Value of the configuration. - :vartype value: str - :ivar source: Source of the configuration. - :vartype source: str - """ - - value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Value of the configuration.""" - source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Source of the configuration.""" - - @overload - def __init__( - self, - *, - value: Optional[str] = None, - source: 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 ConfigurationListForBatchUpdate(_Model): - """A list of server configurations to update. - - :ivar value: The list of server configurations. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate] - :ivar reset_all_to_default: Whether to reset all server parameters to default. Known values - are: "True" and "False". - :vartype reset_all_to_default: str or ~azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault - """ - - value: Optional[list["_models.ConfigurationForBatchUpdate"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The list of server configurations.""" - reset_all_to_default: Optional[Union[str, "_models.ResetAllToDefault"]] = rest_field( - name="resetAllToDefault", visibility=["read", "create", "update", "delete", "query"] - ) - """Whether to reset all server parameters to default. Known values are: \"True\" and \"False\".""" - - @overload - def __init__( - self, - *, - value: Optional[list["_models.ConfigurationForBatchUpdate"]] = None, - reset_all_to_default: Optional[Union[str, "_models.ResetAllToDefault"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ConfigurationListResult(_Model): - """The response of a Configuration list operation. - - :ivar value: The Configuration items on this page. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - value: Optional[list["_models.Configuration"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The Configuration items on this page.""" - next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) - """The link to the next page of items.""" - - @overload - def __init__( - self, - *, - value: Optional[list["_models.Configuration"]] = None, - next_link: 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 ConfigurationProperties(_Model): - """The properties of a configuration. - - :ivar value: Value of the configuration. - :vartype value: str - :ivar current_value: Current value of the configuration. - :vartype current_value: str - :ivar description: Description of the configuration. - :vartype description: str - :ivar documentation_link: The link used to get the document from community or Azure site. - :vartype documentation_link: str - :ivar default_value: Default value of the configuration. - :vartype default_value: str - :ivar data_type: Data type of the configuration. - :vartype data_type: str - :ivar allowed_values: Allowed values of the configuration. - :vartype allowed_values: str - :ivar source: Source of the configuration. Known values are: "system-default" and - "user-override". - :vartype source: str or ~azure.mgmt.mysqlflexibleservers.models.ConfigurationSource - :ivar is_read_only: If is the configuration read only. Known values are: "True" and "False". - :vartype is_read_only: str or ~azure.mgmt.mysqlflexibleservers.models.IsReadOnly - :ivar is_config_pending_restart: If is the configuration pending restart or not. Known values - are: "True" and "False". - :vartype is_config_pending_restart: str or - ~azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart - :ivar is_dynamic_config: If is the configuration dynamic. Known values are: "True" and "False". - :vartype is_dynamic_config: str or ~azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig - """ - - value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Value of the configuration.""" - current_value: Optional[str] = rest_field( - name="currentValue", visibility=["read", "create", "update", "delete", "query"] - ) - """Current value of the configuration.""" - description: Optional[str] = rest_field(visibility=["read"]) - """Description of the configuration.""" - documentation_link: Optional[str] = rest_field(name="documentationLink", visibility=["read"]) - """The link used to get the document from community or Azure site.""" - default_value: Optional[str] = rest_field(name="defaultValue", visibility=["read"]) - """Default value of the configuration.""" - data_type: Optional[str] = rest_field(name="dataType", visibility=["read"]) - """Data type of the configuration.""" - allowed_values: Optional[str] = rest_field(name="allowedValues", visibility=["read"]) - """Allowed values of the configuration.""" - source: Optional[Union[str, "_models.ConfigurationSource"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Source of the configuration. Known values are: \"system-default\" and \"user-override\".""" - is_read_only: Optional[Union[str, "_models.IsReadOnly"]] = rest_field(name="isReadOnly", visibility=["read"]) - """If is the configuration read only. Known values are: \"True\" and \"False\".""" - is_config_pending_restart: Optional[Union[str, "_models.IsConfigPendingRestart"]] = rest_field( - name="isConfigPendingRestart", visibility=["read"] - ) - """If is the configuration pending restart or not. Known values are: \"True\" and \"False\".""" - is_dynamic_config: Optional[Union[str, "_models.IsDynamicConfig"]] = rest_field( - name="isDynamicConfig", visibility=["read"] - ) - """If is the configuration dynamic. Known values are: \"True\" and \"False\".""" - - @overload - def __init__( - self, - *, - value: Optional[str] = None, - current_value: Optional[str] = None, - source: Optional[Union[str, "_models.ConfigurationSource"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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(ProxyResource): - """Represents 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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a database. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.DatabaseProperties - """ - - properties: Optional["_models.DatabaseProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a database.""" - - __flattened_items = ["charset", "collation"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.DatabaseProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 DatabaseProperties(_Model): - """The properties of a database. - - :ivar charset: The charset of the database. - :vartype charset: str - :ivar collation: The collation of the database. - :vartype collation: str - """ - - charset: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The charset of the database.""" - collation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The collation of the database.""" - - @overload - def __init__( - self, - *, - charset: Optional[str] = None, - collation: 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 DataEncryption(_Model): - """The date encryption for cmk. - - :ivar primary_user_assigned_identity_id: Primary user identity resource id. - :vartype primary_user_assigned_identity_id: str - :ivar primary_key_uri: Primary key uri. - :vartype primary_key_uri: str - :ivar geo_backup_user_assigned_identity_id: Geo backup user identity resource id as identity - can't cross region, need identity in same region as geo backup. - :vartype geo_backup_user_assigned_identity_id: str - :ivar geo_backup_key_uri: Geo backup key uri as key vault can't cross region, need cmk in same - region as geo backup. - :vartype geo_backup_key_uri: str - :ivar type: The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known - values are: "AzureKeyVault" and "SystemManaged". - :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.DataEncryptionType - """ - - primary_user_assigned_identity_id: Optional[str] = rest_field( - name="primaryUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] - ) - """Primary user identity resource id.""" - primary_key_uri: Optional[str] = rest_field( - name="primaryKeyURI", visibility=["read", "create", "update", "delete", "query"] - ) - """Primary key uri.""" - geo_backup_user_assigned_identity_id: Optional[str] = rest_field( - name="geoBackupUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] - ) - """Geo backup user identity resource id as identity can't cross region, need identity in same - region as geo backup.""" - geo_backup_key_uri: Optional[str] = rest_field( - name="geoBackupKeyURI", visibility=["read", "create", "update", "delete", "query"] - ) - """Geo backup key uri as key vault can't cross region, need cmk in same region as geo backup.""" - type: Optional[Union[str, "_models.DataEncryptionType"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known values are: - \"AzureKeyVault\" and \"SystemManaged\".""" - - @overload - def __init__( - self, - *, - primary_user_assigned_identity_id: Optional[str] = None, - primary_key_uri: Optional[str] = None, - geo_backup_user_assigned_identity_id: Optional[str] = None, - geo_backup_key_uri: Optional[str] = None, - type: Optional[Union[str, "_models.DataEncryptionType"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 DelegatedSubnetUsage(_Model): - """Delegated subnet usage data. - - :ivar subnet_name: name of the subnet. - :vartype subnet_name: str - :ivar usage: Number of used delegated subnets. - :vartype usage: int - """ - - subnet_name: Optional[str] = rest_field(name="subnetName", visibility=["read"]) - """name of the subnet.""" - usage: Optional[int] = rest_field(visibility=["read"]) - """Number of used delegated subnets.""" - - -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.mysqlflexibleservers.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 FeatureProperty(_Model): - """Server version capabilities. - - :ivar feature_name: feature name. - :vartype feature_name: str - :ivar feature_value: feature value. - :vartype feature_value: str - """ - - feature_name: Optional[str] = rest_field(name="featureName", visibility=["read"]) - """feature name.""" - feature_value: Optional[str] = rest_field(name="featureValue", visibility=["read"]) - """feature value.""" - - -class FirewallRule(ProxyResource): - """Represents a server 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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a firewall rule. Required. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.FirewallRuleProperties - """ - - properties: "_models.FirewallRuleProperties" = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a firewall rule. Required.""" - - __flattened_items = ["start_ip_address", "end_ip_address"] - - @overload - def __init__( - self, - *, - properties: "_models.FirewallRuleProperties", - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 FirewallRuleProperties(_Model): - """The properties of a server firewall rule. - - :ivar start_ip_address: The start IP address of the server firewall rule. Must be IPv4 format. - Required. - :vartype start_ip_address: str - :ivar end_ip_address: The end IP address of the server firewall rule. Must be IPv4 format. - Required. - :vartype end_ip_address: str - """ - - start_ip_address: str = rest_field( - name="startIpAddress", visibility=["read", "create", "update", "delete", "query"] - ) - """The start IP address of the server firewall rule. Must be IPv4 format. Required.""" - end_ip_address: str = rest_field(name="endIpAddress", visibility=["read", "create", "update", "delete", "query"]) - """The end IP address of the server firewall rule. Must be IPv4 format. Required.""" - - @overload - def __init__( - self, - *, - start_ip_address: str, - end_ip_address: 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 FullBackupStoreDetails(BackupStoreDetails, discriminator="FullBackupStoreDetails"): - """FullBackupStoreDetails is used for scenarios where backup data is streamed/copied over to a - storage destination. - - :ivar sas_uri_list: SASUriList of storage containers where backup data is to be - streamed/copied. Required. - :vartype sas_uri_list: list[str] - :ivar object_type: Type of the specific object - used for deserializing. Required. Default - value is "FullBackupStoreDetails". - :vartype object_type: str - """ - - sas_uri_list: list[str] = rest_field(name="sasUriList", visibility=["read", "create", "update", "delete", "query"]) - """SASUriList of storage containers where backup data is to be streamed/copied. Required.""" - object_type: Literal["FullBackupStoreDetails"] = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Type of the specific object - used for deserializing. Required. Default value is - \"FullBackupStoreDetails\".""" - - @overload - def __init__( - self, - *, - sas_uri_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) - self.object_type = "FullBackupStoreDetails" # type: ignore - - -class GetPrivateDnsZoneSuffixResponse(_Model): - """The response of get private dns zone suffix. - - :ivar private_dns_zone_suffix: Represents the private DNS zone suffix. - :vartype private_dns_zone_suffix: str - """ - - private_dns_zone_suffix: Optional[str] = rest_field( - name="privateDnsZoneSuffix", visibility=["read", "create", "update", "delete", "query"] - ) - """Represents the private DNS zone suffix.""" - - @overload - def __init__( - self, - *, - private_dns_zone_suffix: 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 HighAvailability(_Model): - """High availability properties of a server. - - :ivar mode: High availability mode for a server. Known values are: "Disabled", "ZoneRedundant", - and "SameZone". - :vartype mode: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode - :ivar state: The state of server high availability. Known values are: "NotEnabled", - "CreatingStandby", "Healthy", "FailingOver", and "RemovingStandby". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState - :ivar standby_availability_zone: Availability zone of the standby server. - :vartype standby_availability_zone: str - :ivar replication_mode: HA Replication mode for a server. Known values are: "BinaryLog" and - "RedoLog". - :vartype replication_mode: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationMode - """ - - mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """High availability mode for a server. Known values are: \"Disabled\", \"ZoneRedundant\", and - \"SameZone\".""" - state: Optional[Union[str, "_models.HighAvailabilityState"]] = rest_field(visibility=["read"]) - """The state of server high availability. Known values are: \"NotEnabled\", \"CreatingStandby\", - \"Healthy\", \"FailingOver\", and \"RemovingStandby\".""" - standby_availability_zone: Optional[str] = rest_field( - name="standbyAvailabilityZone", visibility=["read", "create", "update", "delete", "query"] - ) - """Availability zone of the standby server.""" - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = rest_field( - name="replicationMode", visibility=["read", "create", "update", "delete", "query"] - ) - """HA Replication mode for a server. Known values are: \"BinaryLog\" and \"RedoLog\".""" - - @overload - def __init__( - self, - *, - mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = None, - standby_availability_zone: Optional[str] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 HighAvailabilityValidationEstimation(_Model): - """High availability validation properties of a server. - - :ivar estimated_downtime: Estimated seconds of downtime for the deployment. - :vartype estimated_downtime: int - :ivar scheduled_standby_availability_zone: Scheduled Availability zone of the standby server. - :vartype scheduled_standby_availability_zone: str - :ivar expected_standby_availability_zone: Expected Availability zone of the standby server. - :vartype expected_standby_availability_zone: str - """ - - estimated_downtime: Optional[int] = rest_field(name="estimatedDowntime", visibility=["read"]) - """Estimated seconds of downtime for the deployment.""" - scheduled_standby_availability_zone: Optional[str] = rest_field( - name="scheduledStandbyAvailabilityZone", visibility=["read"] - ) - """Scheduled Availability zone of the standby server.""" - expected_standby_availability_zone: Optional[str] = rest_field( - name="expectedStandbyAvailabilityZone", visibility=["read", "create", "update", "delete", "query"] - ) - """Expected Availability zone of the standby server.""" - - @overload - def __init__( - self, - *, - expected_standby_availability_zone: 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 ImportFromStorageResponseType(OperationProgressResponseType, discriminator="ImportFromStorageResponse"): - """ImportFromStorage Response Properties. - - :ivar estimated_completion_time: The estimated time of operation completion. - :vartype estimated_completion_time: ~datetime.datetime - :ivar object_type: Identifies the type of source operation. Required. - :vartype object_type: str or - ~azure.mgmt.mysqlflexibleservers.models.IMPORT_FROM_STORAGE_RESPONSE - """ - - estimated_completion_time: Optional[datetime.datetime] = rest_field( - name="estimatedCompletionTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """The estimated time of operation completion.""" - object_type: Literal[ObjectType.IMPORT_FROM_STORAGE_RESPONSE] = rest_discriminator(name="objectType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Identifies the type of source operation. Required.""" - - @overload - def __init__( - self, - *, - estimated_completion_time: 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) - self.object_type = ObjectType.IMPORT_FROM_STORAGE_RESPONSE # type: ignore - - -class ImportSourceProperties(_Model): - """Import source related properties. - - :ivar storage_type: Storage type of import source. "AzureBlob" - :vartype storage_type: str or ~azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType - :ivar storage_url: Uri of the import source storage. - :vartype storage_url: str - :ivar sas_token: Sas token for accessing source storage. Read and list permissions are required - for sas token. - :vartype sas_token: str - :ivar data_dir_path: Relative path of data directory in storage. - :vartype data_dir_path: str - """ - - storage_type: Optional[Union[str, "_models.ImportSourceStorageType"]] = rest_field( - name="storageType", visibility=["read", "create"] - ) - """Storage type of import source. \"AzureBlob\"""" - storage_url: Optional[str] = rest_field(name="storageUrl", visibility=["read", "create"]) - """Uri of the import source storage.""" - sas_token: Optional[str] = rest_field(name="sasToken", visibility=["create"]) - """Sas token for accessing source storage. Read and list permissions are required for sas token.""" - data_dir_path: Optional[str] = rest_field(name="dataDirPath", visibility=["read", "create"]) - """Relative path of data directory in storage.""" - - @overload - def __init__( - self, - *, - storage_type: Optional[Union[str, "_models.ImportSourceStorageType"]] = None, - storage_url: Optional[str] = None, - sas_token: Optional[str] = None, - data_dir_path: 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 LogFile(ProxyResource): - """Represents a logFile. - - :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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a logFile. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.LogFileProperties - """ - - properties: Optional["_models.LogFileProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a logFile.""" - - __flattened_items = ["size_in_kb", "created_time", "type", "last_modified_time", "url"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.LogFileProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 LogFileProperties(_Model): - """The properties of a logFile. - - :ivar size_in_kb: The size in kb of the logFile. - :vartype size_in_kb: int - :ivar created_time: Creation timestamp of the log file. - :vartype created_time: ~datetime.datetime - :ivar type: Type of the log file. - :vartype type: str - :ivar last_modified_time: Last modified timestamp of the log file. - :vartype last_modified_time: ~datetime.datetime - :ivar url: The url to download the log file from. - :vartype url: str - """ - - size_in_kb: Optional[int] = rest_field(name="sizeInKB", visibility=["read", "create", "update", "delete", "query"]) - """The size in kb of the logFile.""" - created_time: Optional[datetime.datetime] = rest_field( - name="createdTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """Creation timestamp of the log file.""" - type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Type of the log file.""" - last_modified_time: Optional[datetime.datetime] = rest_field( - name="lastModifiedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """Last modified timestamp of the log file.""" - url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The url to download the log file from.""" - - @overload - def __init__( - self, - *, - size_in_kb: Optional[int] = None, - created_time: Optional[datetime.datetime] = None, - type: Optional[str] = None, - last_modified_time: Optional[datetime.datetime] = None, - url: 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 Maintenance(ProxyResource): - """Represents a maintenance. - - :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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a maintenance. Required. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceProperties - """ - - properties: "_models.MaintenanceProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The properties of a maintenance. Required.""" - - __flattened_items = [ - "maintenance_type", - "maintenance_state", - "maintenance_start_time", - "maintenance_end_time", - "maintenance_execution_start_time", - "maintenance_execution_end_time", - "maintenance_available_schedule_min_time", - "maintenance_available_schedule_max_time", - "maintenance_title", - "maintenance_description", - "provisioning_state", - ] - - @overload - def __init__( - self, - *, - properties: "_models.MaintenanceProperties", - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 MaintenancePolicy(_Model): - """Maintenance policy of a server. - - :ivar patch_strategy: The patch strategy of this server. Known values are: "Regular" and - "VirtualCanary". - :vartype patch_strategy: str or ~azure.mgmt.mysqlflexibleservers.models.PatchStrategy - """ - - patch_strategy: Optional[Union[str, "_models.PatchStrategy"]] = rest_field( - name="patchStrategy", visibility=["read", "create", "update", "delete", "query"] - ) - """The patch strategy of this server. Known values are: \"Regular\" and \"VirtualCanary\".""" - - @overload - def __init__( - self, - *, - patch_strategy: Optional[Union[str, "_models.PatchStrategy"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 MaintenanceProperties(_Model): - """The properties of a maintenance resource. - - :ivar maintenance_type: A string defines maintenance type. Known values are: - "RoutineMaintenance", "MinorVersionUpgrade", "SecurityPatches", and "HotFixes". - :vartype maintenance_type: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceType - :ivar maintenance_state: A string describes the maintenance status. Known values are: - "Scheduled", "ReScheduled", "InPreparation", "Processing", "Completed", and "Canceled". - :vartype maintenance_state: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceState - :ivar maintenance_start_time: The start time for a maintenance. - :vartype maintenance_start_time: ~datetime.datetime - :ivar maintenance_end_time: The end time for a maintenance. - :vartype maintenance_end_time: ~datetime.datetime - :ivar maintenance_execution_start_time: The start time for a maintenance execution. - :vartype maintenance_execution_start_time: ~datetime.datetime - :ivar maintenance_execution_end_time: The end time for a maintenance execution. - :vartype maintenance_execution_end_time: ~datetime.datetime - :ivar maintenance_available_schedule_min_time: The min time the maintenance can be rescheduled. - :vartype maintenance_available_schedule_min_time: ~datetime.datetime - :ivar maintenance_available_schedule_max_time: The max time the maintenance can be rescheduled. - :vartype maintenance_available_schedule_max_time: ~datetime.datetime - :ivar maintenance_title: The maintenance title. - :vartype maintenance_title: str - :ivar maintenance_description: The maintenance description. - :vartype maintenance_description: str - :ivar provisioning_state: Provisioning state of the Maintenance. Known values are: "Succeeded", - "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState - """ - - maintenance_type: Optional[Union[str, "_models.MaintenanceType"]] = rest_field( - name="maintenanceType", visibility=["read"] - ) - """A string defines maintenance type. Known values are: \"RoutineMaintenance\", - \"MinorVersionUpgrade\", \"SecurityPatches\", and \"HotFixes\".""" - maintenance_state: Optional[Union[str, "_models.MaintenanceState"]] = rest_field( - name="maintenanceState", visibility=["read"] - ) - """A string describes the maintenance status. Known values are: \"Scheduled\", \"ReScheduled\", - \"InPreparation\", \"Processing\", \"Completed\", and \"Canceled\".""" - maintenance_start_time: Optional[datetime.datetime] = rest_field( - name="maintenanceStartTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """The start time for a maintenance.""" - maintenance_end_time: Optional[datetime.datetime] = rest_field( - name="maintenanceEndTime", visibility=["read"], format="rfc3339" - ) - """The end time for a maintenance.""" - maintenance_execution_start_time: Optional[datetime.datetime] = rest_field( - name="maintenanceExecutionStartTime", visibility=["read"], format="rfc3339" - ) - """The start time for a maintenance execution.""" - maintenance_execution_end_time: Optional[datetime.datetime] = rest_field( - name="maintenanceExecutionEndTime", visibility=["read"], format="rfc3339" - ) - """The end time for a maintenance execution.""" - maintenance_available_schedule_min_time: Optional[datetime.datetime] = rest_field( - name="maintenanceAvailableScheduleMinTime", visibility=["read"], format="rfc3339" - ) - """The min time the maintenance can be rescheduled.""" - maintenance_available_schedule_max_time: Optional[datetime.datetime] = rest_field( - name="maintenanceAvailableScheduleMaxTime", visibility=["read"], format="rfc3339" - ) - """The max time the maintenance can be rescheduled.""" - maintenance_title: Optional[str] = rest_field(name="maintenanceTitle", visibility=["read"]) - """The maintenance title.""" - maintenance_description: Optional[str] = rest_field(name="maintenanceDescription", visibility=["read"]) - """The maintenance description.""" - provisioning_state: Optional[Union[str, "_models.MaintenanceProvisioningState"]] = rest_field( - name="provisioningState", visibility=["read"] - ) - """Provisioning state of the Maintenance. Known values are: \"Succeeded\", \"Creating\", - \"Deleting\", and \"Failed\".""" - - @overload - def __init__( - self, - *, - maintenance_start_time: 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 MaintenancePropertiesForUpdate(_Model): - """The properties of a maintenance update parameter. - - :ivar maintenance_start_time: The start time for a maintenance. - :vartype maintenance_start_time: ~datetime.datetime - """ - - maintenance_start_time: Optional[datetime.datetime] = rest_field( - name="maintenanceStartTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """The start time for a maintenance.""" - - @overload - def __init__( - self, - *, - maintenance_start_time: 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 MaintenanceUpdate(_Model): - """Represents a maintenance update parameter. - - :ivar properties: The properties of a maintenance update parameter. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePropertiesForUpdate - """ - - properties: Optional["_models.MaintenancePropertiesForUpdate"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a maintenance update parameter.""" - - __flattened_items = ["maintenance_start_time"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.MaintenancePropertiesForUpdate"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 MaintenanceWindow(_Model): - """Maintenance window of a server. - - :ivar custom_window: indicates whether custom window is enabled or disabled. - :vartype custom_window: str - :ivar start_hour: start hour for maintenance window. - :vartype start_hour: int - :ivar start_minute: start minute for maintenance window. - :vartype start_minute: int - :ivar day_of_week: day of week for maintenance window. - :vartype day_of_week: int - :ivar batch_of_maintenance: The batch of maintenance when enabled the custom managed - maintenance window of a server. Known values are: "Default", "Batch1", and "Batch2". - :vartype batch_of_maintenance: str or - ~azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance - """ - - custom_window: Optional[str] = rest_field( - name="customWindow", visibility=["read", "create", "update", "delete", "query"] - ) - """indicates whether custom window is enabled or disabled.""" - start_hour: Optional[int] = rest_field(name="startHour", visibility=["read", "create", "update", "delete", "query"]) - """start hour for maintenance window.""" - start_minute: Optional[int] = rest_field( - name="startMinute", visibility=["read", "create", "update", "delete", "query"] - ) - """start minute for maintenance window.""" - day_of_week: Optional[int] = rest_field( - name="dayOfWeek", visibility=["read", "create", "update", "delete", "query"] - ) - """day of week for maintenance window.""" - batch_of_maintenance: Optional[Union[str, "_models.BatchOfMaintenance"]] = rest_field( - name="batchOfMaintenance", visibility=["read", "create", "update", "delete", "query"] - ) - """The batch of maintenance when enabled the custom managed maintenance window of a server. Known - values are: \"Default\", \"Batch1\", and \"Batch2\".""" - - @overload - def __init__( - self, - *, - custom_window: Optional[str] = None, - start_hour: Optional[int] = None, - start_minute: Optional[int] = None, - day_of_week: Optional[int] = None, - batch_of_maintenance: Optional[Union[str, "_models.BatchOfMaintenance"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 MySQLServerIdentity(_Model): - """Properties to configure Identity for Bring your Own Keys. - - :ivar principal_id: ObjectId from the KeyVault. - :vartype principal_id: str - :ivar tenant_id: TenantId from the KeyVault. - :vartype tenant_id: str - :ivar type: Type of managed service identity. "UserAssigned" - :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType - :ivar user_assigned_identities: Metadata of user assigned identity. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity] - """ - - principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) - """ObjectId from the KeyVault.""" - tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) - """TenantId from the KeyVault.""" - type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Type of managed service identity. \"UserAssigned\"""" - user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( - name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] - ) - """Metadata of user assigned identity.""" - - @overload - def __init__( - self, - *, - type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, - user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 MySQLServerSku(_Model): - """Billing information related properties of a server. - - :ivar name: The name of the sku, e.g. Standard_D32s_v3. Required. - :vartype name: str - :ivar tier: The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: - "Burstable", "GeneralPurpose", and "MemoryOptimized". - :vartype tier: str or ~azure.mgmt.mysqlflexibleservers.models.ServerSkuTier - """ - - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name of the sku, e.g. Standard_D32s_v3. Required.""" - tier: Union[str, "_models.ServerSkuTier"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: \"Burstable\", - \"GeneralPurpose\", and \"MemoryOptimized\".""" - - @overload - def __init__( - self, - *, - name: str, - tier: Union[str, "_models.ServerSkuTier"], - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 NameAvailability(_Model): - """Represents a resource name availability. - - :ivar message: Error Message. - :vartype message: str - :ivar name_available: Indicates whether the resource name is available. - :vartype name_available: bool - :ivar reason: Reason for name being unavailable. - :vartype reason: str - """ - - message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Error Message.""" - name_available: Optional[bool] = rest_field( - name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] - ) - """Indicates whether the resource name is available.""" - reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Reason for name being unavailable.""" - - @overload - def __init__( - self, - *, - message: Optional[str] = None, - name_available: Optional[bool] = None, - 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 NameAvailabilityRequest(_Model): - """Request from client to check resource name availability. - - :ivar name: Resource name to verify. Required. - :vartype name: str - :ivar type: Resource type used for verification. - :vartype type: str - """ - - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Resource name to verify. Required.""" - type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Resource type used for verification.""" - - @overload - def __init__( - self, - *, - name: str, - 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 Network(_Model): - """Network related properties of a server. - - :ivar public_network_access: Whether or not public network access is allowed for this server. - Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and - "Disabled". - :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar delegated_subnet_resource_id: Delegated subnet resource id used to setup vnet for a - server. - :vartype delegated_subnet_resource_id: str - :ivar private_dns_zone_resource_id: Private DNS zone resource id. - :vartype private_dns_zone_resource_id: str - """ - - public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( - name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] - ) - """Whether or not public network access is allowed for this server. Value is 'Disabled' when - server has VNet integration. Known values are: \"Enabled\" and \"Disabled\".""" - delegated_subnet_resource_id: Optional[str] = rest_field( - name="delegatedSubnetResourceId", visibility=["read", "create", "update", "delete", "query"] - ) - """Delegated subnet resource id used to setup vnet for a server.""" - private_dns_zone_resource_id: Optional[str] = rest_field( - name="privateDnsZoneResourceId", visibility=["read", "create", "update", "delete", "query"] - ) - """Private DNS zone resource id.""" - - @overload - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - delegated_subnet_resource_id: Optional[str] = None, - private_dns_zone_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 Operation(_Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.mysqlflexibleservers.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", - and "user,system". - :vartype origin: str or ~azure.mgmt.mysqlflexibleservers.models.Origin - :ivar properties: Additional descriptions for the operation. - :vartype properties: dict[str, any] - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - \"Microsoft.Compute/virtualMachines/write\", - \"Microsoft.Compute/virtualMachines/capture/action\".""" - display: Optional["_models.OperationDisplay"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Localized display information for this particular operation.""" - origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) - """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit - logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and - \"user,system\".""" - properties: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Additional descriptions for the operation.""" - - @overload - def __init__( - self, - *, - display: Optional["_models.OperationDisplay"] = None, - properties: Optional[dict[str, Any]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 OperationDisplay(_Model): - """Display metadata associated with the operation. - - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str - """ - - provider: Optional[str] = rest_field(visibility=["read"]) - """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring - Insights\" or \"Microsoft Compute\".""" - resource: Optional[str] = rest_field(visibility=["read"]) - """The localized friendly name of the resource type related to this operation. E.g. \"Virtual - Machines\" or \"Job Schedule Collections\".""" - operation: Optional[str] = rest_field(visibility=["read"]) - """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create - or Update Virtual Machine\", \"Restart Virtual Machine\".""" - description: Optional[str] = rest_field(visibility=["read"]) - """The short, localized friendly description of the operation; suitable for tool tips and detailed - views.""" - - -class OperationStatusResult(_Model): - """The current status of an async operation. - - :ivar id: Fully qualified ID for the async operation. - :vartype id: str - :ivar name: Name of the async operation. - :vartype name: str - :ivar status: Operation status. Required. - :vartype status: str - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar start_time: The start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the operation. - :vartype end_time: ~datetime.datetime - :ivar operations: The operations list. - :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :ivar resource_id: Fully qualified ID of the resource against which the original async - operation was started. - :vartype resource_id: str - """ - - id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Fully qualified ID for the async operation.""" - name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Name of the async operation.""" - status: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Operation status. Required.""" - percent_complete: Optional[float] = rest_field( - name="percentComplete", visibility=["read", "create", "update", "delete", "query"] - ) - """Percent of the operation that is complete.""" - start_time: Optional[datetime.datetime] = rest_field( - name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """The start time of the operation.""" - end_time: Optional[datetime.datetime] = rest_field( - name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """The end time of the operation.""" - operations: Optional[list["_models.OperationStatusResult"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The operations list.""" - error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """If present, details of the operation error.""" - resource_id: Optional[str] = rest_field(name="resourceId", visibility=["read"]) - """Fully qualified ID of the resource against which the original async operation was started.""" - - @overload - def __init__( - self, - *, - status: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - percent_complete: Optional[float] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - operations: Optional[list["_models.OperationStatusResult"]] = None, - 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 OperationProgressResult(OperationStatusResult): - """Represents Operation Results API Response. - - :ivar id: Fully qualified ID for the async operation. - :vartype id: str - :ivar name: Name of the async operation. - :vartype name: str - :ivar status: Operation status. Required. - :vartype status: str - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar start_time: The start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the operation. - :vartype end_time: ~datetime.datetime - :ivar operations: The operations list. - :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :ivar resource_id: Fully qualified ID of the resource against which the original async - operation was started. - :vartype resource_id: str - :ivar properties: The response properties specific to the operation. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType - """ - - properties: Optional["_models.OperationProgressResponseType"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The response properties specific to the operation.""" - - @overload - def __init__( - self, - *, - status: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - percent_complete: Optional[float] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - operations: Optional[list["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetail"] = None, - properties: Optional["_models.OperationProgressResponseType"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 OperationStatusExtendedResult(OperationStatusResult): - """Represents Operation Results API Response. - - :ivar id: Fully qualified ID for the async operation. - :vartype id: str - :ivar name: Name of the async operation. - :vartype name: str - :ivar status: Operation status. Required. - :vartype status: str - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar start_time: The start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the operation. - :vartype end_time: ~datetime.datetime - :ivar operations: The operations list. - :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail - :ivar resource_id: Fully qualified ID of the resource against which the original async - operation was started. - :vartype resource_id: str - :ivar properties: The extended properties of Operation Results. - :vartype properties: dict[str, any] - """ - - properties: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The extended properties of Operation Results.""" - - @overload - def __init__( - self, - *, - status: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - percent_complete: Optional[float] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - operations: Optional[list["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetail"] = None, - properties: Optional[dict[str, Any]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 PrivateEndpoint(_Model): - """The private endpoint resource. - - :ivar id: The resource identifier of the private endpoint. - :vartype id: str - """ - - id: Optional[str] = rest_field(visibility=["read"]) - """The resource identifier of the private endpoint.""" - - -class PrivateEndpointConnection(Resource): - """A private endpoint connection 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.mysqlflexibleservers.models.SystemData - :ivar properties: Resource properties. - :vartype properties: - ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProperties - """ - - properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Resource properties.""" - - __flattened_items = ["group_ids", "private_endpoint", "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 PrivateEndpointConnectionListResult(_Model): - """The response of a PrivateEndpointConnection list operation. - - :ivar value: The PrivateEndpointConnection items on this page. Required. - :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - value: list["_models.PrivateEndpointConnection"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The PrivateEndpointConnection items on this page. Required.""" - next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) - """The link to the next page of items.""" - - @overload - def __init__( - self, - *, - value: list["_models.PrivateEndpointConnection"], - next_link: 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 PrivateEndpointConnectionProperties(_Model): - """Properties of the private endpoint connection. - - :ivar group_ids: The group ids for the private endpoint resource. - :vartype group_ids: list[str] - :ivar private_endpoint: The private endpoint resource. - :vartype private_endpoint: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between service consumer and provider. Required. - :vartype private_link_service_connection_state: - ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState - """ - - group_ids: Optional[list[str]] = rest_field(name="groupIds", visibility=["read"]) - """The group ids for the private endpoint resource.""" - private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( - name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] - ) - """The private endpoint resource.""" - private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( - name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] - ) - """A collection of information about the state of the connection between service consumer and - provider. Required.""" - provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = rest_field( - name="provisioningState", visibility=["read"] - ) - """The provisioning state of the private endpoint connection resource. Known values are: - \"Succeeded\", \"Creating\", \"Deleting\", and \"Failed\".""" - - @overload - def __init__( - self, - *, - private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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(Resource): - """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.mysqlflexibleservers.models.SystemData - :ivar properties: Resource properties. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceProperties - """ - - properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Resource properties.""" - - @overload - def __init__( - self, - *, - properties: Optional["_models.PrivateLinkResourceProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 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 private link DNS zone name. - :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", "create", "update", "delete", "query"] - ) - """The private link resource private link DNS zone name.""" - - @overload - def __init__( - self, - *, - required_zone_names: 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 PrivateLinkServiceConnectionState(_Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the - service. Known values are: \"Pending\", \"Approved\", and \"Rejected\".""" - description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The reason for approval/rejection of the connection.""" - actions_required: Optional[str] = rest_field( - name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] - ) - """A message indicating if changes on the service provider require any updates on the consumer.""" - - @overload - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: 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 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.mysqlflexibleservers.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 Server(TrackedResource): - """Represents 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.mysqlflexibleservers.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: Properties of the server. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerProperties - :ivar identity: The cmk identity for the server. - :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity - :ivar sku: The SKU (pricing tier) of the server. - :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku - """ - - properties: Optional["_models.ServerProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Properties of the server.""" - identity: Optional["_models.MySQLServerIdentity"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The cmk identity for the server.""" - sku: Optional["_models.MySQLServerSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The SKU (pricing tier) of the server.""" - - __flattened_items = [ - "administrator_login", - "administrator_login_password", - "version", - "full_version", - "availability_zone", - "create_mode", - "source_server_resource_id", - "restore_point_in_time", - "replication_role", - "replica_capacity", - "data_encryption", - "state", - "fully_qualified_domain_name", - "database_port", - "storage", - "backup", - "high_availability", - "network", - "private_endpoint_connections", - "maintenance_policy", - "maintenance_window", - "import_source_properties", - "lower_case_table_names", - ] - - @overload - def __init__( - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - properties: Optional["_models.ServerProperties"] = None, - identity: Optional["_models.MySQLServerIdentity"] = None, - sku: Optional["_models.MySQLServerSku"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ServerBackup(ProxyResource): - """Server backup properties. - - :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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a server backup. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupProperties - """ - - properties: Optional["_models.ServerBackupProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a server backup.""" - - __flattened_items = ["backup_type", "completed_time", "source"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.ServerBackupProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ServerBackupProperties(_Model): - """The properties of a server backup. - - :ivar backup_type: Backup type. - :vartype backup_type: str - :ivar completed_time: Backup completed time (ISO8601 format). - :vartype completed_time: ~datetime.datetime - :ivar source: Backup source. - :vartype source: str - """ - - backup_type: Optional[str] = rest_field( - name="backupType", visibility=["read", "create", "update", "delete", "query"] - ) - """Backup type.""" - completed_time: Optional[datetime.datetime] = rest_field( - name="completedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """Backup completed time (ISO8601 format).""" - source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Backup source.""" - - @overload - def __init__( - self, - *, - backup_type: Optional[str] = None, - completed_time: Optional[datetime.datetime] = None, - source: 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 ServerBackupPropertiesV2(_Model): - """The properties of a server backup. - - :ivar backup_name_v2: Backup name. - :vartype backup_name_v2: str - :ivar backup_type: "FULL" - :vartype backup_type: str or ~azure.mgmt.mysqlflexibleservers.models.BackupType - :ivar completed_time: Backup completed time (ISO8601 format). - :vartype completed_time: ~datetime.datetime - :ivar source: Backup source. - :vartype source: str - :ivar provisioning_state: The provisioning state of backup resource. Known values are: - "Succeeded", "Creating", "Deleting", "Failed", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.mysqlflexibleservers.models.ProvisioningState - """ - - backup_name_v2: Optional[str] = rest_field( - name="backupNameV2", visibility=["read", "create", "update", "delete", "query"] - ) - """Backup name.""" - backup_type: Optional[Union[str, "_models.BackupType"]] = rest_field( - name="backupType", visibility=["read", "create", "update", "delete", "query"] - ) - """\"FULL\"""" - completed_time: Optional[datetime.datetime] = rest_field( - name="completedTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) - """Backup completed time (ISO8601 format).""" - source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Backup source.""" - provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( - name="provisioningState", visibility=["read"] - ) - """The provisioning state of backup resource. Known values are: \"Succeeded\", \"Creating\", - \"Deleting\", \"Failed\", and \"Canceled\".""" - - @overload - def __init__( - self, - *, - backup_name_v2: Optional[str] = None, - backup_type: Optional[Union[str, "_models.BackupType"]] = None, - completed_time: Optional[datetime.datetime] = None, - source: 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 ServerBackupV2(ProxyResource): - """Server backup properties. - - :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.mysqlflexibleservers.models.SystemData - :ivar properties: The properties of a server backup. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupPropertiesV2 - """ - - properties: Optional["_models.ServerBackupPropertiesV2"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties of a server backup.""" - - __flattened_items = ["backup_name_v2", "backup_type", "completed_time", "source", "provisioning_state"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.ServerBackupPropertiesV2"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ServerDetachVNetParameter(_Model): - """Parameters to detach Vnet. - - :ivar public_network_access: Whether or not public network access is allowed for this server. - Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and - "Disabled". - :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - """ - - public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( - name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] - ) - """Whether or not public network access is allowed for this server. Value is 'Disabled' when - server has VNet integration. Known values are: \"Enabled\" and \"Disabled\".""" - - @overload - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ServerEditionCapability(_Model): - """Server edition capabilities. - - :ivar name: Server edition name. - :vartype name: str - :ivar supported_storage_editions: A list of supported storage editions. - :vartype supported_storage_editions: - list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] - :ivar supported_server_versions: A list of supported server versions. - :vartype supported_server_versions: - list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability] - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """Server edition name.""" - supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = rest_field( - name="supportedStorageEditions", visibility=["read"] - ) - """A list of supported storage editions.""" - supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = rest_field( - name="supportedServerVersions", visibility=["read"] - ) - """A list of supported server versions.""" - - -class ServerEditionCapabilityV2(_Model): - """Server edition capabilities. - - :ivar name: Server edition name. - :vartype name: str - :ivar default_sku: Default Sku name. - :vartype default_sku: str - :ivar default_storage_size: Default storage size. - :vartype default_storage_size: int - :ivar supported_storage_editions: A list of supported storage editions. - :vartype supported_storage_editions: - list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] - :ivar supported_skus: A list of supported Skus. - :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2] - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """Server edition name.""" - default_sku: Optional[str] = rest_field(name="defaultSku", visibility=["read"]) - """Default Sku name.""" - default_storage_size: Optional[int] = rest_field(name="defaultStorageSize", visibility=["read"]) - """Default storage size.""" - supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = rest_field( - name="supportedStorageEditions", visibility=["read"] - ) - """A list of supported storage editions.""" - supported_skus: Optional[list["_models.SkuCapabilityV2"]] = rest_field(name="supportedSkus", visibility=["read"]) - """A list of supported Skus.""" - - -class ServerForUpdate(_Model): - """Parameters allowed to update for a server. - - :ivar identity: The cmk identity for the server. - :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity - :ivar sku: The SKU (pricing tier) of the server. - :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku - :ivar properties: The properties that can be updated for a server. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ServerPropertiesForUpdate - :ivar tags: Application-specific metadata in the form of key-value pairs. - :vartype tags: dict[str, str] - """ - - identity: Optional["_models.MySQLServerIdentity"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The cmk identity for the server.""" - sku: Optional["_models.MySQLServerSku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The SKU (pricing tier) of the server.""" - properties: Optional["_models.ServerPropertiesForUpdate"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The properties that can be updated for a server.""" - tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Application-specific metadata in the form of key-value pairs.""" - - __flattened_items = [ - "administrator_login_password", - "version", - "storage", - "backup", - "high_availability", - "maintenance_policy", - "maintenance_window", - "replication_role", - "data_encryption", - "network", - ] - - @overload - def __init__( - self, - *, - identity: Optional["_models.MySQLServerIdentity"] = None, - sku: Optional["_models.MySQLServerSku"] = None, - properties: Optional["_models.ServerPropertiesForUpdate"] = 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 ServerGtidSetParameter(_Model): - """Server Gtid set parameters: Replication with Global Transaction Identifiers. - - :ivar gtid_set: The Gtid set of server. - :vartype gtid_set: str - """ - - gtid_set: Optional[str] = rest_field(name="gtidSet", visibility=["read", "create", "update", "delete", "query"]) - """The Gtid set of server.""" - - @overload - def __init__( - self, - *, - gtid_set: 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 ServerProperties(_Model): - """The properties of a server. - - :ivar administrator_login: The administrator's login name of a server. Can only be specified - when the server is being created (and is required for creation). - :vartype administrator_login: str - :ivar administrator_login_password: The password of the administrator login (required for - server creation). - :vartype administrator_login_password: str - :ivar version: Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL - 5.7. Known values are: "5.7", "8.0.21", and "8.4". - :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion - :ivar full_version: Major version and actual engine version. - :vartype full_version: str - :ivar availability_zone: availability Zone information of the server. - :vartype availability_zone: str - :ivar create_mode: The mode to create a new MySQL server. Known values are: "Default", - "PointInTimeRestore", "Replica", and "GeoRestore". - :vartype create_mode: str or ~azure.mgmt.mysqlflexibleservers.models.CreateMode - :ivar source_server_resource_id: The source MySQL server id. - :vartype source_server_resource_id: str - :ivar restore_point_in_time: Restore point creation time (ISO8601 format), specifying the time - to restore from. - :vartype restore_point_in_time: ~datetime.datetime - :ivar replication_role: The replication role. Known values are: "None", "Source", and - "Replica". - :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole - :ivar replica_capacity: The maximum number of replicas that a primary server can have. - :vartype replica_capacity: int - :ivar data_encryption: The Data Encryption for CMK. - :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption - :ivar state: The state of a server. Known values are: "Ready", "Dropping", "Disabled", - "Starting", "Stopping", "Stopped", and "Updating". - :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.ServerState - :ivar fully_qualified_domain_name: The fully qualified domain name of a server. - :vartype fully_qualified_domain_name: str - :ivar database_port: The server database port. Can only be specified when the server is being - created. - :vartype database_port: int - :ivar storage: Storage related properties of a server. - :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage - :ivar backup: Backup related properties of a server. - :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup - :ivar high_availability: High availability related properties of a server. - :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability - :ivar network: Network related properties of a server. - :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network - :ivar private_endpoint_connections: PrivateEndpointConnections related properties of a server. - :vartype private_endpoint_connections: - list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] - :ivar maintenance_policy: Maintenance policy of a server. - :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy - :ivar maintenance_window: Maintenance window of a server. Known issue: cannot be set during - server creation or updated with other properties during server update; must be updated - separately. - :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow - :ivar import_source_properties: Source properties for import from storage. - :vartype import_source_properties: - ~azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties - :ivar lower_case_table_names: The mysql parameter lower_case_table_names. Can only be specified - when the server is being created. Allowed values 1 or 2. - :vartype lower_case_table_names: int - """ - - administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read", "create"]) - """The administrator's login name of a server. Can only be specified when the server is being - created (and is required for creation).""" - administrator_login_password: Optional[str] = rest_field( - name="administratorLoginPassword", visibility=["create", "update"] - ) - """The password of the administrator login (required for server creation).""" - version: Optional[Union[str, "_models.ServerVersion"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL 5.7. Known values - are: \"5.7\", \"8.0.21\", and \"8.4\".""" - full_version: Optional[str] = rest_field(name="fullVersion", visibility=["read"]) - """Major version and actual engine version.""" - availability_zone: Optional[str] = rest_field(name="availabilityZone", visibility=["read", "create"]) - """availability Zone information of the server.""" - create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field(name="createMode", visibility=["create"]) - """The mode to create a new MySQL server. Known values are: \"Default\", \"PointInTimeRestore\", - \"Replica\", and \"GeoRestore\".""" - source_server_resource_id: Optional[str] = rest_field(name="sourceServerResourceId", visibility=["read", "create"]) - """The source MySQL server id.""" - restore_point_in_time: Optional[datetime.datetime] = rest_field( - name="restorePointInTime", visibility=["create"], format="rfc3339" - ) - """Restore point creation time (ISO8601 format), specifying the time to restore from.""" - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field( - name="replicationRole", visibility=["read", "create", "update", "delete", "query"] - ) - """The replication role. Known values are: \"None\", \"Source\", and \"Replica\".""" - replica_capacity: Optional[int] = rest_field(name="replicaCapacity", visibility=["read"]) - """The maximum number of replicas that a primary server can have.""" - data_encryption: Optional["_models.DataEncryption"] = rest_field( - name="dataEncryption", visibility=["read", "create", "update", "delete", "query"] - ) - """The Data Encryption for CMK.""" - state: Optional[Union[str, "_models.ServerState"]] = rest_field(visibility=["read"]) - """The state of a server. Known values are: \"Ready\", \"Dropping\", \"Disabled\", \"Starting\", - \"Stopping\", \"Stopped\", and \"Updating\".""" - fully_qualified_domain_name: Optional[str] = rest_field(name="fullyQualifiedDomainName", visibility=["read"]) - """The fully qualified domain name of a server.""" - database_port: Optional[int] = rest_field(name="databasePort", visibility=["read", "create"]) - """The server database port. Can only be specified when the server is being created.""" - storage: Optional["_models.Storage"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Storage related properties of a server.""" - backup: Optional["_models.Backup"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Backup related properties of a server.""" - high_availability: Optional["_models.HighAvailability"] = rest_field( - name="highAvailability", visibility=["read", "create", "update", "delete", "query"] - ) - """High availability related properties of a server.""" - network: Optional["_models.Network"] = rest_field(visibility=["read", "create"]) - """Network related properties of a server.""" - private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = rest_field( - name="privateEndpointConnections", visibility=["read"] - ) - """PrivateEndpointConnections related properties of a server.""" - maintenance_policy: Optional["_models.MaintenancePolicy"] = rest_field( - name="maintenancePolicy", visibility=["read", "create", "update", "delete", "query"] - ) - """Maintenance policy of a server.""" - maintenance_window: Optional["_models.MaintenanceWindow"] = rest_field( - name="maintenanceWindow", visibility=["read", "update"] - ) - """Maintenance window of a server. Known issue: cannot be set during server creation or updated - with other properties during server update; must be updated separately.""" - import_source_properties: Optional["_models.ImportSourceProperties"] = rest_field( - name="importSourceProperties", visibility=["read", "create", "update", "delete", "query"] - ) - """Source properties for import from storage.""" - lower_case_table_names: Optional[int] = rest_field(name="lowerCaseTableNames", visibility=["read", "create"]) - """The mysql parameter lower_case_table_names. Can only be specified when the server is being - created. Allowed values 1 or 2.""" - - @overload - def __init__( - self, - *, - administrator_login: Optional[str] = None, - administrator_login_password: Optional[str] = None, - version: Optional[Union[str, "_models.ServerVersion"]] = None, - availability_zone: Optional[str] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - source_server_resource_id: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, - data_encryption: Optional["_models.DataEncryption"] = None, - database_port: Optional[int] = None, - storage: Optional["_models.Storage"] = None, - backup: Optional["_models.Backup"] = None, - high_availability: Optional["_models.HighAvailability"] = None, - network: Optional["_models.Network"] = None, - maintenance_policy: Optional["_models.MaintenancePolicy"] = None, - maintenance_window: Optional["_models.MaintenanceWindow"] = None, - import_source_properties: Optional["_models.ImportSourceProperties"] = None, - lower_case_table_names: 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 ServerPropertiesForUpdate(_Model): - """The properties that can be updated for a server. - - :ivar administrator_login_password: The password of the administrator login. - :vartype administrator_login_password: str - :ivar version: Server version. Known values are: "5.7", "8.0.21", and "8.4". - :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion - :ivar storage: Storage related properties of a server. - :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage - :ivar backup: Backup related properties of a server. - :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup - :ivar high_availability: High availability related properties of a server. - :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability - :ivar maintenance_policy: Maintenance policy of a server. - :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy - :ivar maintenance_window: Maintenance window of a server. - :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow - :ivar replication_role: The replication role of the server. Known values are: "None", "Source", - and "Replica". - :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole - :ivar data_encryption: The Data Encryption for CMK. - :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption - :ivar network: Network related properties of a server. - :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network - """ - - administrator_login_password: Optional[str] = rest_field( - name="administratorLoginPassword", visibility=["read", "create", "update", "delete", "query"] - ) - """The password of the administrator login.""" - version: Optional[Union[str, "_models.ServerVersion"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Server version. Known values are: \"5.7\", \"8.0.21\", and \"8.4\".""" - storage: Optional["_models.Storage"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Storage related properties of a server.""" - backup: Optional["_models.Backup"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Backup related properties of a server.""" - high_availability: Optional["_models.HighAvailability"] = rest_field( - name="highAvailability", visibility=["read", "create", "update", "delete", "query"] - ) - """High availability related properties of a server.""" - maintenance_policy: Optional["_models.MaintenancePolicy"] = rest_field( - name="maintenancePolicy", visibility=["read", "create", "update", "delete", "query"] - ) - """Maintenance policy of a server.""" - maintenance_window: Optional["_models.MaintenanceWindow"] = rest_field( - name="maintenanceWindow", visibility=["read", "create", "update", "delete", "query"] - ) - """Maintenance window of a server.""" - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field( - name="replicationRole", visibility=["read", "create", "update", "delete", "query"] - ) - """The replication role of the server. Known values are: \"None\", \"Source\", and \"Replica\".""" - data_encryption: Optional["_models.DataEncryption"] = rest_field( - name="dataEncryption", visibility=["read", "create", "update", "delete", "query"] - ) - """The Data Encryption for CMK.""" - network: Optional["_models.Network"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Network related properties of a server.""" - - @overload - def __init__( - self, - *, - administrator_login_password: Optional[str] = None, - version: Optional[Union[str, "_models.ServerVersion"]] = None, - storage: Optional["_models.Storage"] = None, - backup: Optional["_models.Backup"] = None, - high_availability: Optional["_models.HighAvailability"] = None, - maintenance_policy: Optional["_models.MaintenancePolicy"] = None, - maintenance_window: Optional["_models.MaintenanceWindow"] = None, - replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, - data_encryption: Optional["_models.DataEncryption"] = None, - network: Optional["_models.Network"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ServerRestartParameter(_Model): - """Server restart parameters. - - :ivar restart_with_failover: Whether or not failover to standby server when restarting a server - with high availability enabled. Known values are: "Enabled" and "Disabled". - :vartype restart_with_failover: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar max_failover_seconds: The maximum allowed failover time in seconds. - :vartype max_failover_seconds: int - """ - - restart_with_failover: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( - name="restartWithFailover", visibility=["read", "create", "update", "delete", "query"] - ) - """Whether or not failover to standby server when restarting a server with high availability - enabled. Known values are: \"Enabled\" and \"Disabled\".""" - max_failover_seconds: Optional[int] = rest_field( - name="maxFailoverSeconds", visibility=["read", "create", "update", "delete", "query"] - ) - """The maximum allowed failover time in seconds.""" - - @overload - def __init__( - self, - *, - restart_with_failover: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - max_failover_seconds: 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 ServerVersionCapability(_Model): - """Server version capabilities. - - :ivar name: server version. - :vartype name: str - :ivar supported_skus: A list of supported Skus. - :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapability] - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """server version.""" - supported_skus: Optional[list["_models.SkuCapability"]] = rest_field(name="supportedSkus", visibility=["read"]) - """A list of supported Skus.""" - - -class ServerVersionCapabilityV2(_Model): - """Server version capabilities. - - :ivar name: server version. - :vartype name: str - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """server version.""" - - -class SkuCapability(_Model): - """Sku capability. - - :ivar name: vCore name. - :vartype name: str - :ivar v_cores: supported vCores. - :vartype v_cores: int - :ivar supported_iops: supported IOPS. - :vartype supported_iops: int - :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. - :vartype supported_memory_per_v_core_mb: int - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """vCore name.""" - v_cores: Optional[int] = rest_field(name="vCores", visibility=["read"]) - """supported vCores.""" - supported_iops: Optional[int] = rest_field(name="supportedIops", visibility=["read"]) - """supported IOPS.""" - supported_memory_per_v_core_mb: Optional[int] = rest_field(name="supportedMemoryPerVCoreMB", visibility=["read"]) - """supported memory per vCore in MB.""" - - -class SkuCapabilityV2(_Model): - """Sku capability. - - :ivar name: vCore name. - :vartype name: str - :ivar v_cores: supported vCores. - :vartype v_cores: int - :ivar supported_iops: supported IOPS. - :vartype supported_iops: int - :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. - :vartype supported_memory_per_v_core_mb: int - :ivar supported_zones: Supported zones. - :vartype supported_zones: list[str] - :ivar supported_ha_mode: Supported high availability mode. - :vartype supported_ha_mode: list[str] - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """vCore name.""" - v_cores: Optional[int] = rest_field(name="vCores", visibility=["read"]) - """supported vCores.""" - supported_iops: Optional[int] = rest_field(name="supportedIops", visibility=["read"]) - """supported IOPS.""" - supported_memory_per_v_core_mb: Optional[int] = rest_field(name="supportedMemoryPerVCoreMB", visibility=["read"]) - """supported memory per vCore in MB.""" - supported_zones: Optional[list[str]] = rest_field(name="supportedZones", visibility=["read"]) - """Supported zones.""" - supported_ha_mode: Optional[list[str]] = rest_field(name="supportedHAMode", visibility=["read"]) - """Supported high availability mode.""" - - -class Storage(_Model): - """Storage Profile properties of a server. - - :ivar storage_size_gb: Max storage size allowed for a server. - :vartype storage_size_gb: int - :ivar iops: Storage IOPS for a server. - :vartype iops: int - :ivar auto_grow: Enable Storage Auto Grow or not. Known values are: "Enabled" and "Disabled". - :vartype auto_grow: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar log_on_disk: Enable Log On Disk or not. Known values are: "Enabled" and "Disabled". - :vartype log_on_disk: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar storage_sku: The sku name of the server storage. - :vartype storage_sku: str - :ivar auto_io_scaling: Enable IO Auto Scaling or not. Known values are: "Enabled" and - "Disabled". - :vartype auto_io_scaling: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum - :ivar storage_redundancy: The redundant type of the server storage. The parameter is used for - server creation. Known values are: "LocalRedundancy" and "ZoneRedundancy". - :vartype storage_redundancy: str or - ~azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum - """ - - storage_size_gb: Optional[int] = rest_field( - name="storageSizeGB", visibility=["read", "create", "update", "delete", "query"] - ) - """Max storage size allowed for a server.""" - iops: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Storage IOPS for a server.""" - auto_grow: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( - name="autoGrow", visibility=["read", "create", "update", "delete", "query"] - ) - """Enable Storage Auto Grow or not. Known values are: \"Enabled\" and \"Disabled\".""" - log_on_disk: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( - name="logOnDisk", visibility=["read", "create", "update", "delete", "query"] - ) - """Enable Log On Disk or not. Known values are: \"Enabled\" and \"Disabled\".""" - storage_sku: Optional[str] = rest_field(name="storageSku", visibility=["read"]) - """The sku name of the server storage.""" - auto_io_scaling: Optional[Union[str, "_models.EnableStatusEnum"]] = rest_field( - name="autoIoScaling", visibility=["read", "create", "update", "delete", "query"] - ) - """Enable IO Auto Scaling or not. Known values are: \"Enabled\" and \"Disabled\".""" - storage_redundancy: Optional[Union[str, "_models.StorageRedundancyEnum"]] = rest_field( - name="storageRedundancy", visibility=["read", "create"] - ) - """The redundant type of the server storage. The parameter is used for server creation. Known - values are: \"LocalRedundancy\" and \"ZoneRedundancy\".""" - - @overload - def __init__( - self, - *, - storage_size_gb: Optional[int] = None, - iops: Optional[int] = None, - auto_grow: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - log_on_disk: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - auto_io_scaling: Optional[Union[str, "_models.EnableStatusEnum"]] = None, - storage_redundancy: Optional[Union[str, "_models.StorageRedundancyEnum"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 StorageEditionCapability(_Model): - """storage edition capability. - - :ivar name: storage edition name. - :vartype name: str - :ivar min_storage_size: The minimal supported storage size. - :vartype min_storage_size: int - :ivar max_storage_size: The maximum supported storage size. - :vartype max_storage_size: int - :ivar min_backup_retention_days: Minimal backup retention days. - :vartype min_backup_retention_days: int - :ivar max_backup_retention_days: Maximum backup retention days. - :vartype max_backup_retention_days: int - :ivar min_backup_interval_hours: Minimal backup interval hours. - :vartype min_backup_interval_hours: int - :ivar max_backup_interval_hours: Maximum backup interval hours. - :vartype max_backup_interval_hours: int - """ - - name: Optional[str] = rest_field(visibility=["read"]) - """storage edition name.""" - min_storage_size: Optional[int] = rest_field(name="minStorageSize", visibility=["read"]) - """The minimal supported storage size.""" - max_storage_size: Optional[int] = rest_field(name="maxStorageSize", visibility=["read"]) - """The maximum supported storage size.""" - min_backup_retention_days: Optional[int] = rest_field(name="minBackupRetentionDays", visibility=["read"]) - """Minimal backup retention days.""" - max_backup_retention_days: Optional[int] = rest_field(name="maxBackupRetentionDays", visibility=["read"]) - """Maximum backup retention days.""" - min_backup_interval_hours: Optional[int] = rest_field(name="minBackupIntervalHours", visibility=["read"]) - """Minimal backup interval hours.""" - max_backup_interval_hours: Optional[int] = rest_field(name="maxBackupIntervalHours", visibility=["read"]) - """Maximum backup interval hours.""" - - -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.mysqlflexibleservers.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.mysqlflexibleservers.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 UserAssignedIdentity(_Model): - """Metadata of user assigned identity. - - :ivar principal_id: Principal Id of user assigned identity. - :vartype principal_id: str - :ivar client_id: Client Id of user assigned identity. - :vartype client_id: str - """ - - principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) - """Principal Id of user assigned identity.""" - client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) - """Client Id of user assigned identity.""" - - -class ValidateBackupResponse(_Model): - """Represents ValidateBackup API Response. - - :ivar properties: The response properties of a pre backup operation. - :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponseProperties - """ - - properties: Optional["_models.ValidateBackupResponseProperties"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The response properties of a pre backup operation.""" - - __flattened_items = ["number_of_containers"] - - @overload - def __init__( - self, - *, - properties: Optional["_models.ValidateBackupResponseProperties"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[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 ValidateBackupResponseProperties(_Model): - """ValidateBackup Response Properties. - - :ivar number_of_containers: Estimated no of storage containers required for resource data to be - backed up. - :vartype number_of_containers: int - """ - - number_of_containers: Optional[int] = rest_field( - name="numberOfContainers", visibility=["read", "create", "update", "delete", "query"] - ) - """Estimated no of storage containers required for resource data to be backed up.""" - - @overload - def __init__( - self, - *, - number_of_containers: 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 VirtualNetworkSubnetUsageParameter(_Model): - """Virtual network subnet usage parameter. - - :ivar virtual_network_resource_id: Virtual network resource id. - :vartype virtual_network_resource_id: str - """ - - virtual_network_resource_id: Optional[str] = rest_field( - name="virtualNetworkResourceId", visibility=["read", "create", "update", "delete", "query"] - ) - """Virtual network resource id.""" - - @overload - def __init__( - self, - *, - virtual_network_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 VirtualNetworkSubnetUsageResult(_Model): - """Virtual network subnet usage data. - - :ivar location: The location name. - :vartype location: str - :ivar subscription_id: The subscription id. - :vartype subscription_id: str - :ivar delegated_subnets_usage: A list of delegated subnet usage. - :vartype delegated_subnets_usage: - list[~azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage] - """ - - location: Optional[str] = rest_field(visibility=["read"]) - """The location name.""" - subscription_id: Optional[str] = rest_field(name="subscriptionId", visibility=["read"]) - """The subscription id.""" - delegated_subnets_usage: Optional[list["_models.DelegatedSubnetUsage"]] = rest_field( - name="delegatedSubnetsUsage", visibility=["read"] - ) - """A list of delegated subnet usage.""" diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py new file mode 100644 index 000000000000..42117027a7e5 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_models_py3.py @@ -0,0 +1,4066 @@ +# 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 azure ad administrators. + + :ivar value: The list of azure ad administrator of a server. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AzureADAdministrator]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[list["_models.AzureADAdministrator"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of azure ad administrator of a server. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + """ + + _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"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + """ + + +class AdvancedThreatProtection(ProxyResource): + """A server's Advanced Threat Protection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar creation_time: Specifies the UTC creation time of the policy. + :vartype creation_time: ~datetime.datetime + :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: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState + :ivar provisioning_state: Provisioning state of the Threat Protection. Known values are: + "Succeeded", "Updating", "Canceled", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "creation_time": {"readonly": True}, + "provisioning_state": {"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"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "state": {"key": "properties.state", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + 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: "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState + """ + super().__init__(**kwargs) + self.creation_time: Optional[datetime.datetime] = None + self.state = state + self.provisioning_state: Optional[Union[str, "_models.AdvancedThreatProtectionProvisioningState"]] = None + + +class AdvancedThreatProtectionForUpdate(_serialization.Model): + """Parameters allowed to update advanced threat protection for a server. + + :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: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState + """ + + _attribute_map = { + "state": {"key": "properties.state", "type": "str"}, + } + + 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: "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionState + """ + super().__init__(**kwargs) + self.state = state + + +class AdvancedThreatProtectionListResult(_serialization.Model): + """The response of a AdvancedThreatProtection list operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The AdvancedThreatProtection items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AdvancedThreatProtection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[list["_models.AdvancedThreatProtection"]] = None + self.next_link = next_link + + +class AzureADAdministrator(ProxyResource): + """Represents a Administrator. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" + :vartype administrator_type: str or ~azure.mgmt.mysqlflexibleservers.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 identity_resource_id: The resource id of the identity used for AAD Authentication. + :vartype identity_resource_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"}, + "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"}, + "identity_resource_id": {"key": "properties.identityResourceId", "type": "str"}, + } + + def __init__( + self, + *, + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, + login: Optional[str] = None, + sid: Optional[str] = None, + tenant_id: Optional[str] = None, + identity_resource_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword administrator_type: Type of the sever administrator. "ActiveDirectory" + :paramtype administrator_type: str or ~azure.mgmt.mysqlflexibleservers.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 + :keyword identity_resource_id: The resource id of the identity used for AAD Authentication. + :paramtype identity_resource_id: str + """ + super().__init__(**kwargs) + self.administrator_type = administrator_type + self.login = login + self.sid = sid + self.tenant_id = tenant_id + self.identity_resource_id = identity_resource_id + + +class Backup(_serialization.Model): + """Storage Profile properties of a server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar backup_retention_days: Backup retention days for the server. + :vartype backup_retention_days: int + :ivar backup_interval_hours: Backup interval hours for the server. + :vartype backup_interval_hours: int + :ivar geo_redundant_backup: Whether or not geo redundant backup is enabled. Known values are: + "Enabled" and "Disabled". + :vartype geo_redundant_backup: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar earliest_restore_date: Earliest restore point creation time (ISO8601 format). + :vartype earliest_restore_date: ~datetime.datetime + """ + + _validation = { + "earliest_restore_date": {"readonly": True}, + } + + _attribute_map = { + "backup_retention_days": {"key": "backupRetentionDays", "type": "int"}, + "backup_interval_hours": {"key": "backupIntervalHours", "type": "int"}, + "geo_redundant_backup": {"key": "geoRedundantBackup", "type": "str"}, + "earliest_restore_date": {"key": "earliestRestoreDate", "type": "iso-8601"}, + } + + def __init__( + self, + *, + backup_retention_days: Optional[int] = None, + backup_interval_hours: Optional[int] = None, + geo_redundant_backup: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword backup_retention_days: Backup retention days for the server. + :paramtype backup_retention_days: int + :keyword backup_interval_hours: Backup interval hours for the server. + :paramtype backup_interval_hours: int + :keyword geo_redundant_backup: Whether or not geo redundant backup is enabled. Known values + are: "Enabled" and "Disabled". + :paramtype geo_redundant_backup: str or + ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + """ + super().__init__(**kwargs) + self.backup_retention_days = backup_retention_days + self.backup_interval_hours = backup_interval_hours + self.geo_redundant_backup = geo_redundant_backup + self.earliest_restore_date: Optional[datetime.datetime] = None + + +class BackupRequestBase(_serialization.Model): + """BackupRequestBase is the base for all backup request. + + All required parameters must be populated in order to send to server. + + :ivar backup_settings: Backup Settings. Required. + :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings + """ + + _validation = { + "backup_settings": {"required": True}, + } + + _attribute_map = { + "backup_settings": {"key": "backupSettings", "type": "BackupSettings"}, + } + + def __init__(self, *, backup_settings: "_models.BackupSettings", **kwargs: Any) -> None: + """ + :keyword backup_settings: Backup Settings. Required. + :paramtype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings + """ + super().__init__(**kwargs) + self.backup_settings = backup_settings + + +class BackupAndExportRequest(BackupRequestBase): + """BackupAndExport API Request. + + All required parameters must be populated in order to send to server. + + :ivar backup_settings: Backup Settings. Required. + :vartype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings + :ivar target_details: Backup Target Store Details. Required. + :vartype target_details: ~azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails + """ + + _validation = { + "backup_settings": {"required": True}, + "target_details": {"required": True}, + } + + _attribute_map = { + "backup_settings": {"key": "backupSettings", "type": "BackupSettings"}, + "target_details": {"key": "targetDetails", "type": "BackupStoreDetails"}, + } + + def __init__( + self, *, backup_settings: "_models.BackupSettings", target_details: "_models.BackupStoreDetails", **kwargs: Any + ) -> None: + """ + :keyword backup_settings: Backup Settings. Required. + :paramtype backup_settings: ~azure.mgmt.mysqlflexibleservers.models.BackupSettings + :keyword target_details: Backup Target Store Details. Required. + :paramtype target_details: ~azure.mgmt.mysqlflexibleservers.models.BackupStoreDetails + """ + super().__init__(backup_settings=backup_settings, **kwargs) + self.target_details = target_details + + +class BackupAndExportResponse(ProxyResource): + """Represents BackupAndExportAPI Response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar error: The error object. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :ivar status: The operation status. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Canceled". + :vartype status: str or ~azure.mgmt.mysqlflexibleservers.models.OperationStatus + :ivar start_time: Start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: Operation progress (0-100). + :vartype percent_complete: float + :ivar datasource_size_in_bytes: Size of datasource in bytes. + :vartype datasource_size_in_bytes: int + :ivar data_transferred_in_bytes: Data transferred in bytes. + :vartype data_transferred_in_bytes: int + :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in + key-value pairs. + :vartype backup_metadata: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "error": {"key": "error", "type": "ErrorDetail"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "datasource_size_in_bytes": {"key": "properties.datasourceSizeInBytes", "type": "int"}, + "data_transferred_in_bytes": {"key": "properties.dataTransferredInBytes", "type": "int"}, + "backup_metadata": {"key": "properties.backupMetadata", "type": "str"}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + status: Optional[Union[str, "_models.OperationStatus"]] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + percent_complete: Optional[float] = None, + datasource_size_in_bytes: Optional[int] = None, + data_transferred_in_bytes: Optional[int] = None, + backup_metadata: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :keyword status: The operation status. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Canceled". + :paramtype status: str or ~azure.mgmt.mysqlflexibleservers.models.OperationStatus + :keyword start_time: Start time. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time. + :paramtype end_time: ~datetime.datetime + :keyword percent_complete: Operation progress (0-100). + :paramtype percent_complete: float + :keyword datasource_size_in_bytes: Size of datasource in bytes. + :paramtype datasource_size_in_bytes: int + :keyword data_transferred_in_bytes: Data transferred in bytes. + :paramtype data_transferred_in_bytes: int + :keyword backup_metadata: Metadata related to backup to be stored for restoring resource in + key-value pairs. + :paramtype backup_metadata: str + """ + super().__init__(**kwargs) + self.error = error + self.status = status + self.start_time = start_time + self.end_time = end_time + self.percent_complete = percent_complete + self.datasource_size_in_bytes = datasource_size_in_bytes + self.data_transferred_in_bytes = data_transferred_in_bytes + self.backup_metadata = backup_metadata + + +class OperationProgressResponseType(_serialization.Model): + """Represents the response properties specific to the operation. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BackupAndExportResponseType, ImportFromStorageResponseType + + All required parameters must be populated in order to send to server. + + :ivar object_type: Identifies the type of source operation. Required. Known values are: + "BackupAndExportResponse" and "ImportFromStorageResponse". + :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType + """ + + _validation = { + "object_type": {"required": True}, + } + + _attribute_map = { + "object_type": {"key": "objectType", "type": "str"}, + } + + _subtype_map = { + "object_type": { + "BackupAndExportResponse": "BackupAndExportResponseType", + "ImportFromStorageResponse": "ImportFromStorageResponseType", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.object_type: Optional[str] = None + + +class BackupAndExportResponseType(OperationProgressResponseType): + """BackupAndExport Response Properties. + + All required parameters must be populated in order to send to server. + + :ivar object_type: Identifies the type of source operation. Required. Known values are: + "BackupAndExportResponse" and "ImportFromStorageResponse". + :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType + :ivar datasource_size_in_bytes: Size of datasource in bytes. + :vartype datasource_size_in_bytes: int + :ivar data_transferred_in_bytes: Data transferred in bytes. + :vartype data_transferred_in_bytes: int + :ivar backup_metadata: Metadata related to backup to be stored for restoring resource in + key-value pairs. + :vartype backup_metadata: str + """ + + _validation = { + "object_type": {"required": True}, + } + + _attribute_map = { + "object_type": {"key": "objectType", "type": "str"}, + "datasource_size_in_bytes": {"key": "datasourceSizeInBytes", "type": "int"}, + "data_transferred_in_bytes": {"key": "dataTransferredInBytes", "type": "int"}, + "backup_metadata": {"key": "backupMetadata", "type": "str"}, + } + + def __init__( + self, + *, + datasource_size_in_bytes: Optional[int] = None, + data_transferred_in_bytes: Optional[int] = None, + backup_metadata: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword datasource_size_in_bytes: Size of datasource in bytes. + :paramtype datasource_size_in_bytes: int + :keyword data_transferred_in_bytes: Data transferred in bytes. + :paramtype data_transferred_in_bytes: int + :keyword backup_metadata: Metadata related to backup to be stored for restoring resource in + key-value pairs. + :paramtype backup_metadata: str + """ + super().__init__(**kwargs) + self.object_type: str = "BackupAndExportResponse" + self.datasource_size_in_bytes = datasource_size_in_bytes + self.data_transferred_in_bytes = data_transferred_in_bytes + self.backup_metadata = backup_metadata + + +class BackupSettings(_serialization.Model): + """Backup Settings. + + All required parameters must be populated in order to send to server. + + :ivar backup_name: The name of the backup. Required. + :vartype backup_name: str + :ivar backup_format: Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT + USE). Known values are: "CollatedFormat" and "Raw". + :vartype backup_format: str or ~azure.mgmt.mysqlflexibleservers.models.BackupFormat + """ + + _validation = { + "backup_name": {"required": True, "pattern": r"(^[a-z0-9]$)|(^[a-z0-9][a-z0-9-]*[a-z0-9]$)"}, + } + + _attribute_map = { + "backup_name": {"key": "backupName", "type": "str"}, + "backup_format": {"key": "backupFormat", "type": "str"}, + } + + def __init__( + self, *, backup_name: str, backup_format: Optional[Union[str, "_models.BackupFormat"]] = None, **kwargs: Any + ) -> None: + """ + :keyword backup_name: The name of the backup. Required. + :paramtype backup_name: str + :keyword backup_format: Backup Format for the current backup. (CollatedFormat is INTERNAL – DO + NOT USE). Known values are: "CollatedFormat" and "Raw". + :paramtype backup_format: str or ~azure.mgmt.mysqlflexibleservers.models.BackupFormat + """ + super().__init__(**kwargs) + self.backup_name = backup_name + self.backup_format = backup_format + + +class BackupStoreDetails(_serialization.Model): + """Details about the target where the backup content will be stored. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FullBackupStoreDetails + + All required parameters must be populated in order to send to server. + + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + """ + + _validation = { + "object_type": {"required": True}, + } + + _attribute_map = { + "object_type": {"key": "objectType", "type": "str"}, + } + + _subtype_map = {"object_type": {"FullBackupStoreDetails": "FullBackupStoreDetails"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.object_type: Optional[str] = None + + +class CapabilitiesListResult(_serialization.Model): + """location capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The CapabilityProperties items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[CapabilityProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[list["_models.CapabilityProperties"]] = None + self.next_link = next_link + + +class Capability(ProxyResource): + """Represents a location capability set. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar supported_geo_backup_regions: supported geo backup regions. + :vartype supported_geo_backup_regions: list[str] + :ivar supported_flexible_server_editions: A list of supported flexible server editions. + :vartype supported_flexible_server_editions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapabilityV2] + :ivar supported_server_versions: A list of supported server versions. + :vartype supported_server_versions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapabilityV2] + :ivar supported_features: A list of supported features. + :vartype supported_features: list[~azure.mgmt.mysqlflexibleservers.models.FeatureProperty] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "supported_geo_backup_regions": {"readonly": True}, + "supported_flexible_server_editions": {"readonly": True}, + "supported_server_versions": {"readonly": True}, + "supported_features": {"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"}, + "supported_geo_backup_regions": {"key": "properties.supportedGeoBackupRegions", "type": "[str]"}, + "supported_flexible_server_editions": { + "key": "properties.supportedFlexibleServerEditions", + "type": "[ServerEditionCapabilityV2]", + }, + "supported_server_versions": { + "key": "properties.supportedServerVersions", + "type": "[ServerVersionCapabilityV2]", + }, + "supported_features": {"key": "properties.supportedFeatures", "type": "[FeatureProperty]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.supported_geo_backup_regions: Optional[list[str]] = None + self.supported_flexible_server_editions: Optional[list["_models.ServerEditionCapabilityV2"]] = None + self.supported_server_versions: Optional[list["_models.ServerVersionCapabilityV2"]] = None + self.supported_features: Optional[list["_models.FeatureProperty"]] = None + + +class CapabilityProperties(_serialization.Model): + """Location capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar zone: zone name. + :vartype zone: str + :ivar supported_ha_mode: Supported high availability mode. + :vartype supported_ha_mode: list[str] + :ivar supported_geo_backup_regions: supported geo backup regions. + :vartype supported_geo_backup_regions: list[str] + :ivar supported_flexible_server_editions: A list of supported flexible server editions. + :vartype supported_flexible_server_editions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerEditionCapability] + """ + + _validation = { + "zone": {"readonly": True}, + "supported_ha_mode": {"readonly": True}, + "supported_geo_backup_regions": {"readonly": True}, + "supported_flexible_server_editions": {"readonly": True}, + } + + _attribute_map = { + "zone": {"key": "zone", "type": "str"}, + "supported_ha_mode": {"key": "supportedHAMode", "type": "[str]"}, + "supported_geo_backup_regions": {"key": "supportedGeoBackupRegions", "type": "[str]"}, + "supported_flexible_server_editions": { + "key": "supportedFlexibleServerEditions", + "type": "[ServerEditionCapability]", + }, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.zone: Optional[str] = None + self.supported_ha_mode: Optional[list[str]] = None + self.supported_geo_backup_regions: Optional[list[str]] = None + self.supported_flexible_server_editions: Optional[list["_models.ServerEditionCapability"]] = None + + +class CapabilitySetsList(_serialization.Model): + """location capability set. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The CapabilitySetsList items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Capability] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Capability]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[list["_models.Capability"]] = None + self.next_link = next_link + + +class Configuration(ProxyResource): + """Represents a Configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar value: Value of the configuration. + :vartype value: str + :ivar current_value: Current value of the configuration. + :vartype current_value: str + :ivar description: Description of the configuration. + :vartype description: str + :ivar documentation_link: The link used to get the document from community or Azure site. + :vartype documentation_link: str + :ivar default_value: Default value of the configuration. + :vartype default_value: str + :ivar data_type: Data type of the configuration. + :vartype data_type: str + :ivar allowed_values: Allowed values of the configuration. + :vartype allowed_values: str + :ivar source: Source of the configuration. Known values are: "system-default" and + "user-override". + :vartype source: str or ~azure.mgmt.mysqlflexibleservers.models.ConfigurationSource + :ivar is_read_only: If is the configuration read only. Known values are: "True" and "False". + :vartype is_read_only: str or ~azure.mgmt.mysqlflexibleservers.models.IsReadOnly + :ivar is_config_pending_restart: If is the configuration pending restart or not. Known values + are: "True" and "False". + :vartype is_config_pending_restart: str or + ~azure.mgmt.mysqlflexibleservers.models.IsConfigPendingRestart + :ivar is_dynamic_config: If is the configuration dynamic. Known values are: "True" and "False". + :vartype is_dynamic_config: str or ~azure.mgmt.mysqlflexibleservers.models.IsDynamicConfig + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "description": {"readonly": True}, + "documentation_link": {"readonly": True}, + "default_value": {"readonly": True}, + "data_type": {"readonly": True}, + "allowed_values": {"readonly": True}, + "is_read_only": {"readonly": True}, + "is_config_pending_restart": {"readonly": True}, + "is_dynamic_config": {"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"}, + "value": {"key": "properties.value", "type": "str"}, + "current_value": {"key": "properties.currentValue", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "documentation_link": {"key": "properties.documentationLink", "type": "str"}, + "default_value": {"key": "properties.defaultValue", "type": "str"}, + "data_type": {"key": "properties.dataType", "type": "str"}, + "allowed_values": {"key": "properties.allowedValues", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "is_read_only": {"key": "properties.isReadOnly", "type": "str"}, + "is_config_pending_restart": {"key": "properties.isConfigPendingRestart", "type": "str"}, + "is_dynamic_config": {"key": "properties.isDynamicConfig", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + current_value: Optional[str] = None, + source: Optional[Union[str, "_models.ConfigurationSource"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Value of the configuration. + :paramtype value: str + :keyword current_value: Current value of the configuration. + :paramtype current_value: str + :keyword source: Source of the configuration. Known values are: "system-default" and + "user-override". + :paramtype source: str or ~azure.mgmt.mysqlflexibleservers.models.ConfigurationSource + """ + super().__init__(**kwargs) + self.value = value + self.current_value = current_value + self.description: Optional[str] = None + self.documentation_link: Optional[str] = None + self.default_value: Optional[str] = None + self.data_type: Optional[str] = None + self.allowed_values: Optional[str] = None + self.source = source + self.is_read_only: Optional[Union[str, "_models.IsReadOnly"]] = None + self.is_config_pending_restart: Optional[Union[str, "_models.IsConfigPendingRestart"]] = None + self.is_dynamic_config: Optional[Union[str, "_models.IsDynamicConfig"]] = None + + +class ConfigurationForBatchUpdate(_serialization.Model): + """Represents a Configuration. + + :ivar name: Name of the configuration. + :vartype name: str + :ivar value: Value of the configuration. + :vartype value: str + :ivar source: Source of the configuration. + :vartype source: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "properties.value", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + } + + def __init__( + self, *, name: Optional[str] = None, value: Optional[str] = None, source: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword name: Name of the configuration. + :paramtype name: str + :keyword value: Value of the configuration. + :paramtype value: str + :keyword source: Source of the configuration. + :paramtype source: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + self.source = source + + +class ConfigurationListForBatchUpdate(_serialization.Model): + """A list of server configurations to update. + + :ivar value: The list of server configurations. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate] + :ivar reset_all_to_default: Whether to reset all server parameters to default. Known values + are: "True" and "False". + :vartype reset_all_to_default: str or ~azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ConfigurationForBatchUpdate]"}, + "reset_all_to_default": {"key": "resetAllToDefault", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[list["_models.ConfigurationForBatchUpdate"]] = None, + reset_all_to_default: Optional[Union[str, "_models.ResetAllToDefault"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of server configurations. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.ConfigurationForBatchUpdate] + :keyword reset_all_to_default: Whether to reset all server parameters to default. Known values + are: "True" and "False". + :paramtype reset_all_to_default: str or + ~azure.mgmt.mysqlflexibleservers.models.ResetAllToDefault + """ + super().__init__(**kwargs) + self.value = value + self.reset_all_to_default = reset_all_to_default + + +class ConfigurationListResult(_serialization.Model): + """The response of a Configuration list operation. + + :ivar value: The Configuration items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Configuration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.Configuration"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The Configuration items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Database(ProxyResource): + """Represents a Database. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar charset: The charset of the database. + :vartype charset: str + :ivar collation: The collation of the database. + :vartype collation: 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"}, + "charset": {"key": "properties.charset", "type": "str"}, + "collation": {"key": "properties.collation", "type": "str"}, + } + + def __init__(self, *, charset: Optional[str] = None, collation: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword charset: The charset of the database. + :paramtype charset: str + :keyword collation: The collation of the database. + :paramtype collation: str + """ + super().__init__(**kwargs) + self.charset = charset + self.collation = collation + + +class DatabaseListResult(_serialization.Model): + """The response of a Database list operation. + + :ivar value: The Database items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Database] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Database]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.Database"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The Database items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Database] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DataEncryption(_serialization.Model): + """The date encryption for cmk. + + :ivar primary_user_assigned_identity_id: Primary user identity resource id. + :vartype primary_user_assigned_identity_id: str + :ivar primary_key_uri: Primary key uri. + :vartype primary_key_uri: str + :ivar geo_backup_user_assigned_identity_id: Geo backup user identity resource id as identity + can't cross region, need identity in same region as geo backup. + :vartype geo_backup_user_assigned_identity_id: str + :ivar geo_backup_key_uri: Geo backup key uri as key vault can't cross region, need cmk in same + region as geo backup. + :vartype geo_backup_key_uri: str + :ivar type: The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known + values are: "AzureKeyVault" and "SystemManaged". + :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.DataEncryptionType + """ + + _attribute_map = { + "primary_user_assigned_identity_id": {"key": "primaryUserAssignedIdentityId", "type": "str"}, + "primary_key_uri": {"key": "primaryKeyURI", "type": "str"}, + "geo_backup_user_assigned_identity_id": {"key": "geoBackupUserAssignedIdentityId", "type": "str"}, + "geo_backup_key_uri": {"key": "geoBackupKeyURI", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + primary_user_assigned_identity_id: Optional[str] = None, + primary_key_uri: Optional[str] = None, + geo_backup_user_assigned_identity_id: Optional[str] = None, + geo_backup_key_uri: Optional[str] = None, + type: Optional[Union[str, "_models.DataEncryptionType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword primary_user_assigned_identity_id: Primary user identity resource id. + :paramtype primary_user_assigned_identity_id: str + :keyword primary_key_uri: Primary key uri. + :paramtype primary_key_uri: str + :keyword geo_backup_user_assigned_identity_id: Geo backup user identity resource id as identity + can't cross region, need identity in same region as geo backup. + :paramtype geo_backup_user_assigned_identity_id: str + :keyword geo_backup_key_uri: Geo backup key uri as key vault can't cross region, need cmk in + same region as geo backup. + :paramtype geo_backup_key_uri: str + :keyword type: The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. Known + values are: "AzureKeyVault" and "SystemManaged". + :paramtype type: str or ~azure.mgmt.mysqlflexibleservers.models.DataEncryptionType + """ + super().__init__(**kwargs) + self.primary_user_assigned_identity_id = primary_user_assigned_identity_id + self.primary_key_uri = primary_key_uri + self.geo_backup_user_assigned_identity_id = geo_backup_user_assigned_identity_id + self.geo_backup_key_uri = geo_backup_key_uri + self.type = type + + +class DelegatedSubnetUsage(_serialization.Model): + """Delegated subnet usage data. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subnet_name: name of the subnet. + :vartype subnet_name: str + :ivar usage: Number of used delegated subnets. + :vartype usage: int + """ + + _validation = { + "subnet_name": {"readonly": True}, + "usage": {"readonly": True}, + } + + _attribute_map = { + "subnet_name": {"key": "subnetName", "type": "str"}, + "usage": {"key": "usage", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.subnet_name: Optional[str] = None + self.usage: 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.mysqlflexibleservers.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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.mysqlflexibleservers.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class FeatureProperty(_serialization.Model): + """Server version capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar feature_name: feature name. + :vartype feature_name: str + :ivar feature_value: feature value. + :vartype feature_value: str + """ + + _validation = { + "feature_name": {"readonly": True}, + "feature_value": {"readonly": True}, + } + + _attribute_map = { + "feature_name": {"key": "featureName", "type": "str"}, + "feature_value": {"key": "featureValue", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.feature_name: Optional[str] = None + self.feature_value: Optional[str] = None + + +class FirewallRule(ProxyResource): + """Represents a server firewall rule. + + 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: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar start_ip_address: The start IP address of the server firewall rule. Must be IPv4 format. + Required. + :vartype start_ip_address: str + :ivar end_ip_address: The end IP address of the server firewall rule. Must be IPv4 format. + Required. + :vartype end_ip_address: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "start_ip_address": { + "required": True, + "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", + }, + "end_ip_address": { + "required": True, + "pattern": r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", + }, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "start_ip_address": {"key": "properties.startIpAddress", "type": "str"}, + "end_ip_address": {"key": "properties.endIpAddress", "type": "str"}, + } + + def __init__(self, *, start_ip_address: str, end_ip_address: str, **kwargs: Any) -> None: + """ + :keyword start_ip_address: The start IP address of the server firewall rule. Must be IPv4 + format. Required. + :paramtype start_ip_address: str + :keyword end_ip_address: The end IP address of the server firewall rule. Must be IPv4 format. + Required. + :paramtype end_ip_address: str + """ + super().__init__(**kwargs) + self.start_ip_address = start_ip_address + self.end_ip_address = end_ip_address + + +class FirewallRuleListResult(_serialization.Model): + """The response of a FirewallRule list operation. + + :ivar value: The FirewallRule items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[FirewallRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.FirewallRule"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The FirewallRule items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class FullBackupStoreDetails(BackupStoreDetails): + """FullBackupStoreDetails is used for scenarios where backup data is streamed/copied over to a + storage destination. + + All required parameters must be populated in order to send to server. + + :ivar object_type: Type of the specific object - used for deserializing. Required. + :vartype object_type: str + :ivar sas_uri_list: SASUriList of storage containers where backup data is to be + streamed/copied. Required. + :vartype sas_uri_list: list[str] + """ + + _validation = { + "object_type": {"required": True}, + "sas_uri_list": {"required": True}, + } + + _attribute_map = { + "object_type": {"key": "objectType", "type": "str"}, + "sas_uri_list": {"key": "sasUriList", "type": "[str]"}, + } + + def __init__(self, *, sas_uri_list: list[str], **kwargs: Any) -> None: + """ + :keyword sas_uri_list: SASUriList of storage containers where backup data is to be + streamed/copied. Required. + :paramtype sas_uri_list: list[str] + """ + super().__init__(**kwargs) + self.object_type: str = "FullBackupStoreDetails" + self.sas_uri_list = sas_uri_list + + +class GetPrivateDnsZoneSuffixResponse(_serialization.Model): + """The response of get private dns zone suffix. + + :ivar private_dns_zone_suffix: Represents the private DNS zone suffix. + :vartype private_dns_zone_suffix: str + """ + + _attribute_map = { + "private_dns_zone_suffix": {"key": "privateDnsZoneSuffix", "type": "str"}, + } + + def __init__(self, *, private_dns_zone_suffix: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword private_dns_zone_suffix: Represents the private DNS zone suffix. + :paramtype private_dns_zone_suffix: str + """ + super().__init__(**kwargs) + self.private_dns_zone_suffix = private_dns_zone_suffix + + +class HighAvailability(_serialization.Model): + """High availability properties of a server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar mode: High availability mode for a server. Known values are: "Disabled", "ZoneRedundant", + and "SameZone". + :vartype mode: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode + :ivar state: The state of server high availability. Known values are: "NotEnabled", + "CreatingStandby", "Healthy", "FailingOver", and "RemovingStandby". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityState + :ivar standby_availability_zone: Availability zone of the standby server. + :vartype standby_availability_zone: str + :ivar replication_mode: HA Replication mode for a server. Known values are: "BinaryLog" and + "RedoLog". + :vartype replication_mode: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationMode + """ + + _validation = { + "state": {"readonly": True}, + } + + _attribute_map = { + "mode": {"key": "mode", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "standby_availability_zone": {"key": "standbyAvailabilityZone", "type": "str"}, + "replication_mode": {"key": "replicationMode", "type": "str"}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = None, + standby_availability_zone: Optional[str] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword mode: High availability mode for a server. Known values are: "Disabled", + "ZoneRedundant", and "SameZone". + :paramtype mode: str or ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityMode + :keyword standby_availability_zone: Availability zone of the standby server. + :paramtype standby_availability_zone: str + :keyword replication_mode: HA Replication mode for a server. Known values are: "BinaryLog" and + "RedoLog". + :paramtype replication_mode: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationMode + """ + super().__init__(**kwargs) + self.mode = mode + self.state: Optional[Union[str, "_models.HighAvailabilityState"]] = None + self.standby_availability_zone = standby_availability_zone + self.replication_mode = replication_mode + + +class HighAvailabilityValidationEstimation(_serialization.Model): + """High availability validation properties of a server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar estimated_downtime: Estimated seconds of downtime for the deployment. + :vartype estimated_downtime: int + :ivar scheduled_standby_availability_zone: Scheduled Availability zone of the standby server. + :vartype scheduled_standby_availability_zone: str + :ivar expected_standby_availability_zone: Expected Availability zone of the standby server. + :vartype expected_standby_availability_zone: str + """ + + _validation = { + "estimated_downtime": {"readonly": True}, + "scheduled_standby_availability_zone": {"readonly": True}, + } + + _attribute_map = { + "estimated_downtime": {"key": "estimatedDowntime", "type": "int"}, + "scheduled_standby_availability_zone": {"key": "scheduledStandbyAvailabilityZone", "type": "str"}, + "expected_standby_availability_zone": {"key": "expectedStandbyAvailabilityZone", "type": "str"}, + } + + def __init__(self, *, expected_standby_availability_zone: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword expected_standby_availability_zone: Expected Availability zone of the standby server. + :paramtype expected_standby_availability_zone: str + """ + super().__init__(**kwargs) + self.estimated_downtime: Optional[int] = None + self.scheduled_standby_availability_zone: Optional[str] = None + self.expected_standby_availability_zone = expected_standby_availability_zone + + +class ImportFromStorageResponseType(OperationProgressResponseType): + """ImportFromStorage Response Properties. + + All required parameters must be populated in order to send to server. + + :ivar object_type: Identifies the type of source operation. Required. Known values are: + "BackupAndExportResponse" and "ImportFromStorageResponse". + :vartype object_type: str or ~azure.mgmt.mysqlflexibleservers.models.ObjectType + :ivar estimated_completion_time: The estimated time of operation completion. + :vartype estimated_completion_time: ~datetime.datetime + """ + + _validation = { + "object_type": {"required": True}, + } + + _attribute_map = { + "object_type": {"key": "objectType", "type": "str"}, + "estimated_completion_time": {"key": "estimatedCompletionTime", "type": "iso-8601"}, + } + + def __init__(self, *, estimated_completion_time: Optional[datetime.datetime] = None, **kwargs: Any) -> None: + """ + :keyword estimated_completion_time: The estimated time of operation completion. + :paramtype estimated_completion_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.object_type: str = "ImportFromStorageResponse" + self.estimated_completion_time = estimated_completion_time + + +class ImportSourceProperties(_serialization.Model): + """Import source related properties. + + :ivar storage_type: Storage type of import source. "AzureBlob" + :vartype storage_type: str or ~azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType + :ivar storage_url: Uri of the import source storage. + :vartype storage_url: str + :ivar sas_token: Sas token for accessing source storage. Read and list permissions are required + for sas token. + :vartype sas_token: str + :ivar data_dir_path: Relative path of data directory in storage. + :vartype data_dir_path: str + """ + + _attribute_map = { + "storage_type": {"key": "storageType", "type": "str"}, + "storage_url": {"key": "storageUrl", "type": "str"}, + "sas_token": {"key": "sasToken", "type": "str"}, + "data_dir_path": {"key": "dataDirPath", "type": "str"}, + } + + def __init__( + self, + *, + storage_type: Optional[Union[str, "_models.ImportSourceStorageType"]] = None, + storage_url: Optional[str] = None, + sas_token: Optional[str] = None, + data_dir_path: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword storage_type: Storage type of import source. "AzureBlob" + :paramtype storage_type: str or ~azure.mgmt.mysqlflexibleservers.models.ImportSourceStorageType + :keyword storage_url: Uri of the import source storage. + :paramtype storage_url: str + :keyword sas_token: Sas token for accessing source storage. Read and list permissions are + required for sas token. + :paramtype sas_token: str + :keyword data_dir_path: Relative path of data directory in storage. + :paramtype data_dir_path: str + """ + super().__init__(**kwargs) + self.storage_type = storage_type + self.storage_url = storage_url + self.sas_token = sas_token + self.data_dir_path = data_dir_path + + +class LogFile(ProxyResource): + """Represents a logFile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar size_in_kb: The size in kb of the logFile. + :vartype size_in_kb: int + :ivar created_time: Creation timestamp of the log file. + :vartype created_time: ~datetime.datetime + :ivar type_properties_type: Type of the log file. + :vartype type_properties_type: str + :ivar last_modified_time: Last modified timestamp of the log file. + :vartype last_modified_time: ~datetime.datetime + :ivar url: The url to download the log file from. + :vartype url: 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"}, + "size_in_kb": {"key": "properties.sizeInKB", "type": "int"}, + "created_time": {"key": "properties.createdTime", "type": "iso-8601"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "url": {"key": "properties.url", "type": "str"}, + } + + def __init__( + self, + *, + size_in_kb: Optional[int] = None, + created_time: Optional[datetime.datetime] = None, + type_properties_type: Optional[str] = None, + last_modified_time: Optional[datetime.datetime] = None, + url: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword size_in_kb: The size in kb of the logFile. + :paramtype size_in_kb: int + :keyword created_time: Creation timestamp of the log file. + :paramtype created_time: ~datetime.datetime + :keyword type_properties_type: Type of the log file. + :paramtype type_properties_type: str + :keyword last_modified_time: Last modified timestamp of the log file. + :paramtype last_modified_time: ~datetime.datetime + :keyword url: The url to download the log file from. + :paramtype url: str + """ + super().__init__(**kwargs) + self.size_in_kb = size_in_kb + self.created_time = created_time + self.type_properties_type = type_properties_type + self.last_modified_time = last_modified_time + self.url = url + + +class LogFileListResult(_serialization.Model): + """The response of a LogFile list operation. + + :ivar value: The LogFile items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.LogFile] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[LogFile]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.LogFile"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The LogFile items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.LogFile] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Maintenance(ProxyResource): + """Represents a maintenance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar maintenance_type: A string defines maintenance type. Known values are: + "RoutineMaintenance", "MinorVersionUpgrade", "SecurityPatches", and "HotFixes". + :vartype maintenance_type: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceType + :ivar maintenance_state: A string describes the maintenance status. Known values are: + "Scheduled", "ReScheduled", "InPreparation", "Processing", "Completed", and "Canceled". + :vartype maintenance_state: str or ~azure.mgmt.mysqlflexibleservers.models.MaintenanceState + :ivar maintenance_start_time: The start time for a maintenance. + :vartype maintenance_start_time: ~datetime.datetime + :ivar maintenance_end_time: The end time for a maintenance. + :vartype maintenance_end_time: ~datetime.datetime + :ivar maintenance_execution_start_time: The start time for a maintenance execution. + :vartype maintenance_execution_start_time: ~datetime.datetime + :ivar maintenance_execution_end_time: The end time for a maintenance execution. + :vartype maintenance_execution_end_time: ~datetime.datetime + :ivar maintenance_available_schedule_min_time: The min time the maintenance can be rescheduled. + :vartype maintenance_available_schedule_min_time: ~datetime.datetime + :ivar maintenance_available_schedule_max_time: The max time the maintenance can be rescheduled. + :vartype maintenance_available_schedule_max_time: ~datetime.datetime + :ivar maintenance_title: The maintenance title. + :vartype maintenance_title: str + :ivar maintenance_description: The maintenance description. + :vartype maintenance_description: str + :ivar provisioning_state: Provisioning state of the Maintenance. Known values are: "Succeeded", + "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.mysqlflexibleservers.models.MaintenanceProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "maintenance_type": {"readonly": True}, + "maintenance_state": {"readonly": True}, + "maintenance_end_time": {"readonly": True}, + "maintenance_execution_start_time": {"readonly": True}, + "maintenance_execution_end_time": {"readonly": True}, + "maintenance_available_schedule_min_time": {"readonly": True}, + "maintenance_available_schedule_max_time": {"readonly": True}, + "maintenance_title": {"readonly": True}, + "maintenance_description": {"readonly": True}, + "provisioning_state": {"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"}, + "maintenance_type": {"key": "properties.maintenanceType", "type": "str"}, + "maintenance_state": {"key": "properties.maintenanceState", "type": "str"}, + "maintenance_start_time": {"key": "properties.maintenanceStartTime", "type": "iso-8601"}, + "maintenance_end_time": {"key": "properties.maintenanceEndTime", "type": "iso-8601"}, + "maintenance_execution_start_time": {"key": "properties.maintenanceExecutionStartTime", "type": "iso-8601"}, + "maintenance_execution_end_time": {"key": "properties.maintenanceExecutionEndTime", "type": "iso-8601"}, + "maintenance_available_schedule_min_time": { + "key": "properties.maintenanceAvailableScheduleMinTime", + "type": "iso-8601", + }, + "maintenance_available_schedule_max_time": { + "key": "properties.maintenanceAvailableScheduleMaxTime", + "type": "iso-8601", + }, + "maintenance_title": {"key": "properties.maintenanceTitle", "type": "str"}, + "maintenance_description": {"key": "properties.maintenanceDescription", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, *, maintenance_start_time: Optional[datetime.datetime] = None, **kwargs: Any) -> None: + """ + :keyword maintenance_start_time: The start time for a maintenance. + :paramtype maintenance_start_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.maintenance_type: Optional[Union[str, "_models.MaintenanceType"]] = None + self.maintenance_state: Optional[Union[str, "_models.MaintenanceState"]] = None + self.maintenance_start_time = maintenance_start_time + self.maintenance_end_time: Optional[datetime.datetime] = None + self.maintenance_execution_start_time: Optional[datetime.datetime] = None + self.maintenance_execution_end_time: Optional[datetime.datetime] = None + self.maintenance_available_schedule_min_time: Optional[datetime.datetime] = None + self.maintenance_available_schedule_max_time: Optional[datetime.datetime] = None + self.maintenance_title: Optional[str] = None + self.maintenance_description: Optional[str] = None + self.provisioning_state: Optional[Union[str, "_models.MaintenanceProvisioningState"]] = None + + +class MaintenanceListResult(_serialization.Model): + """The response of a Maintenance list operation. + + :ivar value: The Maintenance items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Maintenance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.Maintenance"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The Maintenance items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MaintenancePolicy(_serialization.Model): + """Maintenance policy of a server. + + :ivar patch_strategy: The patch strategy of this server. Known values are: "Regular" and + "VirtualCanary". + :vartype patch_strategy: str or ~azure.mgmt.mysqlflexibleservers.models.PatchStrategy + """ + + _attribute_map = { + "patch_strategy": {"key": "patchStrategy", "type": "str"}, + } + + def __init__(self, *, patch_strategy: Optional[Union[str, "_models.PatchStrategy"]] = None, **kwargs: Any) -> None: + """ + :keyword patch_strategy: The patch strategy of this server. Known values are: "Regular" and + "VirtualCanary". + :paramtype patch_strategy: str or ~azure.mgmt.mysqlflexibleservers.models.PatchStrategy + """ + super().__init__(**kwargs) + self.patch_strategy = patch_strategy + + +class MaintenanceUpdate(_serialization.Model): + """Represents a maintenance update parameter. + + :ivar maintenance_start_time: The start time for a maintenance. + :vartype maintenance_start_time: ~datetime.datetime + """ + + _attribute_map = { + "maintenance_start_time": {"key": "properties.maintenanceStartTime", "type": "iso-8601"}, + } + + def __init__(self, *, maintenance_start_time: Optional[datetime.datetime] = None, **kwargs: Any) -> None: + """ + :keyword maintenance_start_time: The start time for a maintenance. + :paramtype maintenance_start_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.maintenance_start_time = maintenance_start_time + + +class MaintenanceWindow(_serialization.Model): + """Maintenance window of a server. + + :ivar custom_window: indicates whether custom window is enabled or disabled. + :vartype custom_window: str + :ivar start_hour: start hour for maintenance window. + :vartype start_hour: int + :ivar start_minute: start minute for maintenance window. + :vartype start_minute: int + :ivar day_of_week: day of week for maintenance window. + :vartype day_of_week: int + :ivar batch_of_maintenance: The batch of maintenance when enabled the custom managed + maintenance window of a server. Known values are: "Default", "Batch1", and "Batch2". + :vartype batch_of_maintenance: str or + ~azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance + """ + + _attribute_map = { + "custom_window": {"key": "customWindow", "type": "str"}, + "start_hour": {"key": "startHour", "type": "int"}, + "start_minute": {"key": "startMinute", "type": "int"}, + "day_of_week": {"key": "dayOfWeek", "type": "int"}, + "batch_of_maintenance": {"key": "batchOfMaintenance", "type": "str"}, + } + + def __init__( + self, + *, + custom_window: Optional[str] = None, + start_hour: Optional[int] = None, + start_minute: Optional[int] = None, + day_of_week: Optional[int] = None, + batch_of_maintenance: Optional[Union[str, "_models.BatchOfMaintenance"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword custom_window: indicates whether custom window is enabled or disabled. + :paramtype custom_window: str + :keyword start_hour: start hour for maintenance window. + :paramtype start_hour: int + :keyword start_minute: start minute for maintenance window. + :paramtype start_minute: int + :keyword day_of_week: day of week for maintenance window. + :paramtype day_of_week: int + :keyword batch_of_maintenance: The batch of maintenance when enabled the custom managed + maintenance window of a server. Known values are: "Default", "Batch1", and "Batch2". + :paramtype batch_of_maintenance: str or + ~azure.mgmt.mysqlflexibleservers.models.BatchOfMaintenance + """ + super().__init__(**kwargs) + self.custom_window = custom_window + self.start_hour = start_hour + self.start_minute = start_minute + self.day_of_week = day_of_week + self.batch_of_maintenance = batch_of_maintenance + + +class MySQLServerIdentity(_serialization.Model): + """Properties to configure Identity for Bring your Own Keys. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: ObjectId from the KeyVault. + :vartype principal_id: str + :ivar tenant_id: TenantId from the KeyVault. + :vartype tenant_id: str + :ivar type: Type of managed service identity. "UserAssigned" + :vartype type: str or ~azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType + :ivar user_assigned_identities: Metadata of user assigned identity. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of managed service identity. "UserAssigned" + :paramtype type: str or ~azure.mgmt.mysqlflexibleservers.models.ManagedServiceIdentityType + :keyword user_assigned_identities: Metadata of user assigned identity. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.mysqlflexibleservers.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class MySQLServerSku(_serialization.Model): + """Billing information related properties of a server. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the sku, e.g. Standard_D32s_v3. Required. + :vartype name: str + :ivar tier: The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: + "Burstable", "GeneralPurpose", and "MemoryOptimized". + :vartype tier: str or ~azure.mgmt.mysqlflexibleservers.models.ServerSkuTier + """ + + _validation = { + "name": {"required": True}, + "tier": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__(self, *, name: str, tier: Union[str, "_models.ServerSkuTier"], **kwargs: Any) -> None: + """ + :keyword name: The name of the sku, e.g. Standard_D32s_v3. Required. + :paramtype name: str + :keyword tier: The tier of the particular SKU, e.g. GeneralPurpose. Required. Known values are: + "Burstable", "GeneralPurpose", and "MemoryOptimized". + :paramtype tier: str or ~azure.mgmt.mysqlflexibleservers.models.ServerSkuTier + """ + super().__init__(**kwargs) + self.name = name + self.tier = tier + + +class NameAvailability(_serialization.Model): + """Represents a resource name availability. + + :ivar message: Error Message. + :vartype message: str + :ivar name_available: Indicates whether the resource name is available. + :vartype name_available: bool + :ivar reason: Reason for name being unavailable. + :vartype reason: str + """ + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword message: Error Message. + :paramtype message: str + :keyword name_available: Indicates whether the resource name is available. + :paramtype name_available: bool + :keyword reason: Reason for name being unavailable. + :paramtype reason: str + """ + super().__init__(**kwargs) + self.message = message + self.name_available = name_available + self.reason = reason + + +class NameAvailabilityRequest(_serialization.Model): + """Request from client to check resource name availability. + + All required parameters must be populated in order to send to server. + + :ivar name: Resource name to verify. Required. + :vartype name: str + :ivar type: Resource type used for verification. + :vartype type: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, name: str, type: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Resource name to verify. Required. + :paramtype name: str + :keyword type: Resource type used for verification. + :paramtype type: str + """ + super().__init__(**kwargs) + self.name = name + self.type = type + + +class Network(_serialization.Model): + """Network related properties of a server. + + :ivar public_network_access: Whether or not public network access is allowed for this server. + Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar delegated_subnet_resource_id: Delegated subnet resource id used to setup vnet for a + server. + :vartype delegated_subnet_resource_id: str + :ivar private_dns_zone_resource_id: Private DNS zone resource id. + :vartype private_dns_zone_resource_id: str + """ + + _attribute_map = { + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "delegated_subnet_resource_id": {"key": "delegatedSubnetResourceId", "type": "str"}, + "private_dns_zone_resource_id": {"key": "privateDnsZoneResourceId", "type": "str"}, + } + + def __init__( + self, + *, + public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + delegated_subnet_resource_id: Optional[str] = None, + private_dns_zone_resource_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword public_network_access: Whether or not public network access is allowed for this + server. Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and + "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :keyword delegated_subnet_resource_id: Delegated subnet resource id used to setup vnet for a + server. + :paramtype delegated_subnet_resource_id: str + :keyword private_dns_zone_resource_id: Private DNS zone resource id. + :paramtype private_dns_zone_resource_id: str + """ + super().__init__(**kwargs) + self.public_network_access = public_network_access + self.delegated_subnet_resource_id = delegated_subnet_resource_id + self.private_dns_zone_resource_id = private_dns_zone_resource_id + + +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.mysqlflexibleservers.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.mysqlflexibleservers.models.Origin + :ivar properties: Additional descriptions for the operation. + :vartype properties: dict[str, any] + """ + + _validation = { + "name": {"readonly": True}, + "origin": {"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, + *, + display: Optional["_models.OperationDisplay"] = None, + properties: Optional[dict[str, Any]] = None, + **kwargs: Any + ) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.mysqlflexibleservers.models.OperationDisplay + :keyword properties: Additional descriptions for the operation. + :paramtype properties: dict[str, any] + """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.display = display + self.origin: Optional[Union[str, "_models.Origin"]] = None + self.properties = properties + + +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, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :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 OperationListResult(_serialization.Model): + """The static parameters for a resource group based resource. + + :ivar value: The Operation items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Operation] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The Operation items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Operation] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + 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: Fully qualified ID for the async operation. + :vartype id: str + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + """ + + _validation = { + "resource_id": {"readonly": True}, + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[list["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + """ + super().__init__(**kwargs) + self.id = id + self.resource_id: Optional[str] = None + self.name = name + self.status = status + self.percent_complete = percent_complete + self.start_time = start_time + self.end_time = end_time + self.operations = operations + self.error = error + + +class OperationProgressResult(OperationStatusResult): + """Represents Operation Results API Response. + + 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: Fully qualified ID for the async operation. + :vartype id: str + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :ivar properties: The response properties specific to the operation. + :vartype properties: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType + """ + + _validation = { + "resource_id": {"readonly": True}, + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, + "properties": {"key": "properties", "type": "OperationProgressResponseType"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[list["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + properties: Optional["_models.OperationProgressResponseType"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :keyword properties: The response properties specific to the operation. + :paramtype properties: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResponseType + """ + super().__init__( + id=id, + name=name, + status=status, + percent_complete=percent_complete, + start_time=start_time, + end_time=end_time, + operations=operations, + error=error, + **kwargs + ) + self.properties = properties + + +class OperationStatusExtendedResult(OperationStatusResult): + """Represents Operation Results API Response. + + 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: Fully qualified ID for the async operation. + :vartype id: str + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :ivar properties: The extended properties of Operation Results. + :vartype properties: dict[str, any] + """ + + _validation = { + "resource_id": {"readonly": True}, + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, + "properties": {"key": "properties", "type": "{object}"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[list["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + properties: Optional[dict[str, Any]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.mysqlflexibleservers.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.mysqlflexibleservers.models.ErrorDetail + :keyword properties: The extended properties of Operation Results. + :paramtype properties: dict[str, any] + """ + super().__init__( + id=id, + name=name, + status=status, + percent_complete=percent_complete, + start_time=start_time, + end_time=end_time, + operations=operations, + error=error, + **kwargs + ) + self.properties = properties + + +class PrivateEndpoint(_serialization.Model): + """The private endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for private endpoint. + :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 PrivateEndpointConnection(Resource): + """The private endpoint connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar group_ids: The group ids for the private endpoint resource. + :vartype group_ids: list[str] + :ivar private_endpoint: The private endpoint resource. + :vartype private_endpoint: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "group_ids": {"key": "properties.groupIds", "type": "[str]"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The private endpoint resource. + :paramtype private_endpoint: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.group_ids: Optional[list[str]] = None + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """The response of a PrivateEndpointConnection list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The PrivateEndpointConnection items on this page. Required. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: list["_models.PrivateEndpointConnection"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The PrivateEndpointConnection items on this page. Required. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkResource(Resource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :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 private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"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"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, *, required_zone_names: Optional[list[str]] = None, **kwargs: Any) -> None: + """ + :keyword required_zone_names: The private link resource private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id: Optional[str] = None + self.required_members: Optional[list[str]] = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + } + + def __init__(self, *, value: Optional[list["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResource] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or + ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", and "Rejected". + :paramtype status: str or + ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + 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: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class Server(TrackedResource): + """Represents a 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: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.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 identity: The cmk identity for the server. + :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity + :ivar sku: The SKU (pricing tier) of the server. + :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku + :ivar administrator_login: The administrator's login name of a server. Can only be specified + when the server is being created (and is required for creation). + :vartype administrator_login: str + :ivar administrator_login_password: The password of the administrator login (required for + server creation). + :vartype administrator_login_password: str + :ivar version: Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL + 5.7. Known values are: "5.7", "8.0.21", and "8.4". + :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion + :ivar full_version: Major version and actual engine version. + :vartype full_version: str + :ivar availability_zone: availability Zone information of the server. + :vartype availability_zone: str + :ivar create_mode: The mode to create a new MySQL server. Known values are: "Default", + "PointInTimeRestore", "Replica", and "GeoRestore". + :vartype create_mode: str or ~azure.mgmt.mysqlflexibleservers.models.CreateMode + :ivar source_server_resource_id: The source MySQL server id. + :vartype source_server_resource_id: str + :ivar restore_point_in_time: Restore point creation time (ISO8601 format), specifying the time + to restore from. + :vartype restore_point_in_time: ~datetime.datetime + :ivar replication_role: The replication role. Known values are: "None", "Source", and + "Replica". + :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole + :ivar replica_capacity: The maximum number of replicas that a primary server can have. + :vartype replica_capacity: int + :ivar data_encryption: The Data Encryption for CMK. + :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption + :ivar state: The state of a server. Known values are: "Ready", "Dropping", "Disabled", + "Starting", "Stopping", "Stopped", and "Updating". + :vartype state: str or ~azure.mgmt.mysqlflexibleservers.models.ServerState + :ivar fully_qualified_domain_name: The fully qualified domain name of a server. + :vartype fully_qualified_domain_name: str + :ivar database_port: The server database port. Can only be specified when the server is being + created. + :vartype database_port: int + :ivar storage: Storage related properties of a server. + :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage + :ivar backup: Backup related properties of a server. + :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup + :ivar high_availability: High availability related properties of a server. + :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability + :ivar network: Network related properties of a server. + :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network + :ivar private_endpoint_connections: PrivateEndpointConnections related properties of a server. + :vartype private_endpoint_connections: + list[~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnection] + :ivar maintenance_policy: Maintenance policy of a server. + :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy + :ivar maintenance_window: Maintenance window of a server. Known issue: cannot be set during + server creation or updated with other properties during server update; must be updated + separately. + :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow + :ivar import_source_properties: Source properties for import from storage. + :vartype import_source_properties: + ~azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties + :ivar lower_case_table_names: The mysql parameter lower_case_table_names. Can only be specified + when the server is being created. Allowed values 1 or 2. + :vartype lower_case_table_names: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "full_version": {"readonly": True}, + "replica_capacity": {"readonly": True, "minimum": 0}, + "state": {"readonly": True}, + "fully_qualified_domain_name": {"readonly": True}, + "private_endpoint_connections": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "MySQLServerIdentity"}, + "sku": {"key": "sku", "type": "MySQLServerSku"}, + "administrator_login": {"key": "properties.administratorLogin", "type": "str"}, + "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "full_version": {"key": "properties.fullVersion", "type": "str"}, + "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, + "create_mode": {"key": "properties.createMode", "type": "str"}, + "source_server_resource_id": {"key": "properties.sourceServerResourceId", "type": "str"}, + "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, + "replication_role": {"key": "properties.replicationRole", "type": "str"}, + "replica_capacity": {"key": "properties.replicaCapacity", "type": "int"}, + "data_encryption": {"key": "properties.dataEncryption", "type": "DataEncryption"}, + "state": {"key": "properties.state", "type": "str"}, + "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, + "database_port": {"key": "properties.databasePort", "type": "int"}, + "storage": {"key": "properties.storage", "type": "Storage"}, + "backup": {"key": "properties.backup", "type": "Backup"}, + "high_availability": {"key": "properties.highAvailability", "type": "HighAvailability"}, + "network": {"key": "properties.network", "type": "Network"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "maintenance_policy": {"key": "properties.maintenancePolicy", "type": "MaintenancePolicy"}, + "maintenance_window": {"key": "properties.maintenanceWindow", "type": "MaintenanceWindow"}, + "import_source_properties": {"key": "properties.importSourceProperties", "type": "ImportSourceProperties"}, + "lower_case_table_names": {"key": "properties.lowerCaseTableNames", "type": "int"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.MySQLServerIdentity"] = None, + sku: Optional["_models.MySQLServerSku"] = None, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + version: Optional[Union[str, "_models.ServerVersion"]] = None, + availability_zone: Optional[str] = None, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + source_server_resource_id: Optional[str] = None, + restore_point_in_time: Optional[datetime.datetime] = None, + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, + data_encryption: Optional["_models.DataEncryption"] = None, + database_port: Optional[int] = None, + storage: Optional["_models.Storage"] = None, + backup: Optional["_models.Backup"] = None, + high_availability: Optional["_models.HighAvailability"] = None, + network: Optional["_models.Network"] = None, + maintenance_policy: Optional["_models.MaintenancePolicy"] = None, + maintenance_window: Optional["_models.MaintenanceWindow"] = None, + import_source_properties: Optional["_models.ImportSourceProperties"] = None, + lower_case_table_names: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: The cmk identity for the server. + :paramtype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity + :keyword sku: The SKU (pricing tier) of the server. + :paramtype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku + :keyword administrator_login: The administrator's login name of a server. Can only be specified + when the server is being created (and is required for creation). + :paramtype administrator_login: str + :keyword administrator_login_password: The password of the administrator login (required for + server creation). + :paramtype administrator_login_password: str + :keyword version: Major version of MySQL. 8.0.21 stands for MySQL 8.0, 5.7.44 stands for MySQL + 5.7. Known values are: "5.7", "8.0.21", and "8.4". + :paramtype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion + :keyword availability_zone: availability Zone information of the server. + :paramtype availability_zone: str + :keyword create_mode: The mode to create a new MySQL server. Known values are: "Default", + "PointInTimeRestore", "Replica", and "GeoRestore". + :paramtype create_mode: str or ~azure.mgmt.mysqlflexibleservers.models.CreateMode + :keyword source_server_resource_id: The source MySQL server id. + :paramtype source_server_resource_id: str + :keyword restore_point_in_time: Restore point creation time (ISO8601 format), specifying the + time to restore from. + :paramtype restore_point_in_time: ~datetime.datetime + :keyword replication_role: The replication role. Known values are: "None", "Source", and + "Replica". + :paramtype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole + :keyword data_encryption: The Data Encryption for CMK. + :paramtype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption + :keyword database_port: The server database port. Can only be specified when the server is + being created. + :paramtype database_port: int + :keyword storage: Storage related properties of a server. + :paramtype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage + :keyword backup: Backup related properties of a server. + :paramtype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup + :keyword high_availability: High availability related properties of a server. + :paramtype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability + :keyword network: Network related properties of a server. + :paramtype network: ~azure.mgmt.mysqlflexibleservers.models.Network + :keyword maintenance_policy: Maintenance policy of a server. + :paramtype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy + :keyword maintenance_window: Maintenance window of a server. Known issue: cannot be set during + server creation or updated with other properties during server update; must be updated + separately. + :paramtype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow + :keyword import_source_properties: Source properties for import from storage. + :paramtype import_source_properties: + ~azure.mgmt.mysqlflexibleservers.models.ImportSourceProperties + :keyword lower_case_table_names: The mysql parameter lower_case_table_names. Can only be + specified when the server is being created. Allowed values 1 or 2. + :paramtype lower_case_table_names: int + """ + super().__init__(tags=tags, location=location, **kwargs) + self.identity = identity + self.sku = sku + self.administrator_login = administrator_login + self.administrator_login_password = administrator_login_password + self.version = version + self.full_version: Optional[str] = None + self.availability_zone = availability_zone + self.create_mode = create_mode + self.source_server_resource_id = source_server_resource_id + self.restore_point_in_time = restore_point_in_time + self.replication_role = replication_role + self.replica_capacity: Optional[int] = None + self.data_encryption = data_encryption + self.state: Optional[Union[str, "_models.ServerState"]] = None + self.fully_qualified_domain_name: Optional[str] = None + self.database_port = database_port + self.storage = storage + self.backup = backup + self.high_availability = high_availability + self.network = network + self.private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = None + self.maintenance_policy = maintenance_policy + self.maintenance_window = maintenance_window + self.import_source_properties = import_source_properties + self.lower_case_table_names = lower_case_table_names + + +class ServerBackup(ProxyResource): + """Server backup properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar backup_type: Backup type. + :vartype backup_type: str + :ivar completed_time: Backup completed time (ISO8601 format). + :vartype completed_time: ~datetime.datetime + :ivar source: Backup source. + :vartype source: 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"}, + "backup_type": {"key": "properties.backupType", "type": "str"}, + "completed_time": {"key": "properties.completedTime", "type": "iso-8601"}, + "source": {"key": "properties.source", "type": "str"}, + } + + def __init__( + self, + *, + backup_type: Optional[str] = None, + completed_time: Optional[datetime.datetime] = None, + source: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword backup_type: Backup type. + :paramtype backup_type: str + :keyword completed_time: Backup completed time (ISO8601 format). + :paramtype completed_time: ~datetime.datetime + :keyword source: Backup source. + :paramtype source: str + """ + super().__init__(**kwargs) + self.backup_type = backup_type + self.completed_time = completed_time + self.source = source + + +class ServerBackupListResult(_serialization.Model): + """The response of a ServerBackup list operation. + + :ivar value: The ServerBackup items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ServerBackup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.ServerBackup"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The ServerBackup items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServerBackupV2(ProxyResource): + """Server backup properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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.mysqlflexibleservers.models.SystemData + :ivar backup_name_v2: Backup name. + :vartype backup_name_v2: str + :ivar backup_type: "FULL" + :vartype backup_type: str or ~azure.mgmt.mysqlflexibleservers.models.BackupType + :ivar completed_time: Backup completed time (ISO8601 format). + :vartype completed_time: ~datetime.datetime + :ivar source: Backup source. + :vartype source: str + :ivar provisioning_state: The provisioning state of backup resource. Known values are: + "Succeeded", "Creating", "Deleting", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.mysqlflexibleservers.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"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"}, + "backup_name_v2": {"key": "properties.backupNameV2", "type": "str"}, + "backup_type": {"key": "properties.backupType", "type": "str"}, + "completed_time": {"key": "properties.completedTime", "type": "iso-8601"}, + "source": {"key": "properties.source", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + backup_name_v2: Optional[str] = None, + backup_type: Optional[Union[str, "_models.BackupType"]] = None, + completed_time: Optional[datetime.datetime] = None, + source: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword backup_name_v2: Backup name. + :paramtype backup_name_v2: str + :keyword backup_type: "FULL" + :paramtype backup_type: str or ~azure.mgmt.mysqlflexibleservers.models.BackupType + :keyword completed_time: Backup completed time (ISO8601 format). + :paramtype completed_time: ~datetime.datetime + :keyword source: Backup source. + :paramtype source: str + """ + super().__init__(**kwargs) + self.backup_name_v2 = backup_name_v2 + self.backup_type = backup_type + self.completed_time = completed_time + self.source = source + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + + +class ServerBackupV2ListResult(_serialization.Model): + """The response of a ServerBackupV2 list operation. + + :ivar value: The ServerBackupV2 items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ServerBackupV2]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.ServerBackupV2"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The ServerBackupV2 items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServerDetachVNetParameter(_serialization.Model): + """Parameters to detach Vnet. + + :ivar public_network_access: Whether or not public network access is allowed for this server. + Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + """ + + _attribute_map = { + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + } + + def __init__( + self, *, public_network_access: Optional[Union[str, "_models.EnableStatusEnum"]] = None, **kwargs: Any + ) -> None: + """ + :keyword public_network_access: Whether or not public network access is allowed for this + server. Value is 'Disabled' when server has VNet integration. Known values are: "Enabled" and + "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + """ + super().__init__(**kwargs) + self.public_network_access = public_network_access + + +class ServerEditionCapability(_serialization.Model): + """Server edition capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Server edition name. + :vartype name: str + :ivar supported_storage_editions: A list of supported storage editions. + :vartype supported_storage_editions: + list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] + :ivar supported_server_versions: A list of supported server versions. + :vartype supported_server_versions: + list[~azure.mgmt.mysqlflexibleservers.models.ServerVersionCapability] + """ + + _validation = { + "name": {"readonly": True}, + "supported_storage_editions": {"readonly": True}, + "supported_server_versions": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "supported_storage_editions": {"key": "supportedStorageEditions", "type": "[StorageEditionCapability]"}, + "supported_server_versions": {"key": "supportedServerVersions", "type": "[ServerVersionCapability]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = None + self.supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = None + + +class ServerEditionCapabilityV2(_serialization.Model): + """Server edition capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Server edition name. + :vartype name: str + :ivar default_sku: Default Sku name. + :vartype default_sku: str + :ivar default_storage_size: Default storage size. + :vartype default_storage_size: int + :ivar supported_storage_editions: A list of supported storage editions. + :vartype supported_storage_editions: + list[~azure.mgmt.mysqlflexibleservers.models.StorageEditionCapability] + :ivar supported_skus: A list of supported Skus. + :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapabilityV2] + """ + + _validation = { + "name": {"readonly": True}, + "default_sku": {"readonly": True}, + "default_storage_size": {"readonly": True}, + "supported_storage_editions": {"readonly": True}, + "supported_skus": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "default_sku": {"key": "defaultSku", "type": "str"}, + "default_storage_size": {"key": "defaultStorageSize", "type": "int"}, + "supported_storage_editions": {"key": "supportedStorageEditions", "type": "[StorageEditionCapability]"}, + "supported_skus": {"key": "supportedSkus", "type": "[SkuCapabilityV2]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.default_sku: Optional[str] = None + self.default_storage_size: Optional[int] = None + self.supported_storage_editions: Optional[list["_models.StorageEditionCapability"]] = None + self.supported_skus: Optional[list["_models.SkuCapabilityV2"]] = None + + +class ServerForUpdate(_serialization.Model): + """Parameters allowed to update for a server. + + :ivar identity: The cmk identity for the server. + :vartype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity + :ivar sku: The SKU (pricing tier) of the server. + :vartype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku + :ivar tags: Application-specific metadata in the form of key-value pairs. + :vartype tags: dict[str, str] + :ivar administrator_login_password: The password of the administrator login. + :vartype administrator_login_password: str + :ivar version: Server version. Known values are: "5.7", "8.0.21", and "8.4". + :vartype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion + :ivar storage: Storage related properties of a server. + :vartype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage + :ivar backup: Backup related properties of a server. + :vartype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup + :ivar high_availability: High availability related properties of a server. + :vartype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability + :ivar maintenance_policy: Maintenance policy of a server. + :vartype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy + :ivar maintenance_window: Maintenance window of a server. + :vartype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow + :ivar replication_role: The replication role of the server. Known values are: "None", "Source", + and "Replica". + :vartype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole + :ivar data_encryption: The Data Encryption for CMK. + :vartype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption + :ivar network: Network related properties of a server. + :vartype network: ~azure.mgmt.mysqlflexibleservers.models.Network + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "MySQLServerIdentity"}, + "sku": {"key": "sku", "type": "MySQLServerSku"}, + "tags": {"key": "tags", "type": "{str}"}, + "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "storage": {"key": "properties.storage", "type": "Storage"}, + "backup": {"key": "properties.backup", "type": "Backup"}, + "high_availability": {"key": "properties.highAvailability", "type": "HighAvailability"}, + "maintenance_policy": {"key": "properties.maintenancePolicy", "type": "MaintenancePolicy"}, + "maintenance_window": {"key": "properties.maintenanceWindow", "type": "MaintenanceWindow"}, + "replication_role": {"key": "properties.replicationRole", "type": "str"}, + "data_encryption": {"key": "properties.dataEncryption", "type": "DataEncryption"}, + "network": {"key": "properties.network", "type": "Network"}, + } + + def __init__( + self, + *, + identity: Optional["_models.MySQLServerIdentity"] = None, + sku: Optional["_models.MySQLServerSku"] = None, + tags: Optional[dict[str, str]] = None, + administrator_login_password: Optional[str] = None, + version: Optional[Union[str, "_models.ServerVersion"]] = None, + storage: Optional["_models.Storage"] = None, + backup: Optional["_models.Backup"] = None, + high_availability: Optional["_models.HighAvailability"] = None, + maintenance_policy: Optional["_models.MaintenancePolicy"] = None, + maintenance_window: Optional["_models.MaintenanceWindow"] = None, + replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None, + data_encryption: Optional["_models.DataEncryption"] = None, + network: Optional["_models.Network"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: The cmk identity for the server. + :paramtype identity: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerIdentity + :keyword sku: The SKU (pricing tier) of the server. + :paramtype sku: ~azure.mgmt.mysqlflexibleservers.models.MySQLServerSku + :keyword tags: Application-specific metadata in the form of key-value pairs. + :paramtype tags: dict[str, str] + :keyword administrator_login_password: The password of the administrator login. + :paramtype administrator_login_password: str + :keyword version: Server version. Known values are: "5.7", "8.0.21", and "8.4". + :paramtype version: str or ~azure.mgmt.mysqlflexibleservers.models.ServerVersion + :keyword storage: Storage related properties of a server. + :paramtype storage: ~azure.mgmt.mysqlflexibleservers.models.Storage + :keyword backup: Backup related properties of a server. + :paramtype backup: ~azure.mgmt.mysqlflexibleservers.models.Backup + :keyword high_availability: High availability related properties of a server. + :paramtype high_availability: ~azure.mgmt.mysqlflexibleservers.models.HighAvailability + :keyword maintenance_policy: Maintenance policy of a server. + :paramtype maintenance_policy: ~azure.mgmt.mysqlflexibleservers.models.MaintenancePolicy + :keyword maintenance_window: Maintenance window of a server. + :paramtype maintenance_window: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceWindow + :keyword replication_role: The replication role of the server. Known values are: "None", + "Source", and "Replica". + :paramtype replication_role: str or ~azure.mgmt.mysqlflexibleservers.models.ReplicationRole + :keyword data_encryption: The Data Encryption for CMK. + :paramtype data_encryption: ~azure.mgmt.mysqlflexibleservers.models.DataEncryption + :keyword network: Network related properties of a server. + :paramtype network: ~azure.mgmt.mysqlflexibleservers.models.Network + """ + super().__init__(**kwargs) + self.identity = identity + self.sku = sku + self.tags = tags + self.administrator_login_password = administrator_login_password + self.version = version + self.storage = storage + self.backup = backup + self.high_availability = high_availability + self.maintenance_policy = maintenance_policy + self.maintenance_window = maintenance_window + self.replication_role = replication_role + self.data_encryption = data_encryption + self.network = network + + +class ServerGtidSetParameter(_serialization.Model): + """Server Gtid set parameters: Replication with Global Transaction Identifiers. + + :ivar gtid_set: The Gtid set of server. + :vartype gtid_set: str + """ + + _attribute_map = { + "gtid_set": {"key": "gtidSet", "type": "str"}, + } + + def __init__(self, *, gtid_set: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword gtid_set: The Gtid set of server. + :paramtype gtid_set: str + """ + super().__init__(**kwargs) + self.gtid_set = gtid_set + + +class ServerListResult(_serialization.Model): + """The response of a Server list operation. + + :ivar value: The Server items on this page. + :vartype value: list[~azure.mgmt.mysqlflexibleservers.models.Server] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Server]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[list["_models.Server"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The Server items on this page. + :paramtype value: list[~azure.mgmt.mysqlflexibleservers.models.Server] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServerRestartParameter(_serialization.Model): + """Server restart parameters. + + :ivar restart_with_failover: Whether or not failover to standby server when restarting a server + with high availability enabled. Known values are: "Enabled" and "Disabled". + :vartype restart_with_failover: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar max_failover_seconds: The maximum allowed failover time in seconds. + :vartype max_failover_seconds: int + """ + + _attribute_map = { + "restart_with_failover": {"key": "restartWithFailover", "type": "str"}, + "max_failover_seconds": {"key": "maxFailoverSeconds", "type": "int"}, + } + + def __init__( + self, + *, + restart_with_failover: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + max_failover_seconds: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword restart_with_failover: Whether or not failover to standby server when restarting a + server with high availability enabled. Known values are: "Enabled" and "Disabled". + :paramtype restart_with_failover: str or + ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :keyword max_failover_seconds: The maximum allowed failover time in seconds. + :paramtype max_failover_seconds: int + """ + super().__init__(**kwargs) + self.restart_with_failover = restart_with_failover + self.max_failover_seconds = max_failover_seconds + + +class ServerVersionCapability(_serialization.Model): + """Server version capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: server version. + :vartype name: str + :ivar supported_skus: A list of supported Skus. + :vartype supported_skus: list[~azure.mgmt.mysqlflexibleservers.models.SkuCapability] + """ + + _validation = { + "name": {"readonly": True}, + "supported_skus": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "supported_skus": {"key": "supportedSkus", "type": "[SkuCapability]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.supported_skus: Optional[list["_models.SkuCapability"]] = None + + +class ServerVersionCapabilityV2(_serialization.Model): + """Server version capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: server version. + :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 SkuCapability(_serialization.Model): + """Sku capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: vCore name. + :vartype name: str + :ivar v_cores: supported vCores. + :vartype v_cores: int + :ivar supported_iops: supported IOPS. + :vartype supported_iops: int + :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. + :vartype supported_memory_per_v_core_mb: int + """ + + _validation = { + "name": {"readonly": True}, + "v_cores": {"readonly": True}, + "supported_iops": {"readonly": True}, + "supported_memory_per_v_core_mb": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "v_cores": {"key": "vCores", "type": "int"}, + "supported_iops": {"key": "supportedIops", "type": "int"}, + "supported_memory_per_v_core_mb": {"key": "supportedMemoryPerVCoreMB", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.v_cores: Optional[int] = None + self.supported_iops: Optional[int] = None + self.supported_memory_per_v_core_mb: Optional[int] = None + + +class SkuCapabilityV2(_serialization.Model): + """Sku capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: vCore name. + :vartype name: str + :ivar v_cores: supported vCores. + :vartype v_cores: int + :ivar supported_iops: supported IOPS. + :vartype supported_iops: int + :ivar supported_memory_per_v_core_mb: supported memory per vCore in MB. + :vartype supported_memory_per_v_core_mb: int + :ivar supported_zones: Supported zones. + :vartype supported_zones: list[str] + :ivar supported_ha_mode: Supported high availability mode. + :vartype supported_ha_mode: list[str] + """ + + _validation = { + "name": {"readonly": True}, + "v_cores": {"readonly": True}, + "supported_iops": {"readonly": True}, + "supported_memory_per_v_core_mb": {"readonly": True}, + "supported_zones": {"readonly": True}, + "supported_ha_mode": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "v_cores": {"key": "vCores", "type": "int"}, + "supported_iops": {"key": "supportedIops", "type": "int"}, + "supported_memory_per_v_core_mb": {"key": "supportedMemoryPerVCoreMB", "type": "int"}, + "supported_zones": {"key": "supportedZones", "type": "[str]"}, + "supported_ha_mode": {"key": "supportedHAMode", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.v_cores: Optional[int] = None + self.supported_iops: Optional[int] = None + self.supported_memory_per_v_core_mb: Optional[int] = None + self.supported_zones: Optional[list[str]] = None + self.supported_ha_mode: Optional[list[str]] = None + + +class Storage(_serialization.Model): + """Storage Profile properties of a server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar storage_size_gb: Max storage size allowed for a server. + :vartype storage_size_gb: int + :ivar iops: Storage IOPS for a server. + :vartype iops: int + :ivar auto_grow: Enable Storage Auto Grow or not. Known values are: "Enabled" and "Disabled". + :vartype auto_grow: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar log_on_disk: Enable Log On Disk or not. Known values are: "Enabled" and "Disabled". + :vartype log_on_disk: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar storage_sku: The sku name of the server storage. + :vartype storage_sku: str + :ivar auto_io_scaling: Enable IO Auto Scaling or not. Known values are: "Enabled" and + "Disabled". + :vartype auto_io_scaling: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :ivar storage_redundancy: The redundant type of the server storage. The parameter is used for + server creation. Known values are: "LocalRedundancy" and "ZoneRedundancy". + :vartype storage_redundancy: str or + ~azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum + """ + + _validation = { + "storage_sku": {"readonly": True}, + } + + _attribute_map = { + "storage_size_gb": {"key": "storageSizeGB", "type": "int"}, + "iops": {"key": "iops", "type": "int"}, + "auto_grow": {"key": "autoGrow", "type": "str"}, + "log_on_disk": {"key": "logOnDisk", "type": "str"}, + "storage_sku": {"key": "storageSku", "type": "str"}, + "auto_io_scaling": {"key": "autoIoScaling", "type": "str"}, + "storage_redundancy": {"key": "storageRedundancy", "type": "str"}, + } + + def __init__( + self, + *, + storage_size_gb: Optional[int] = None, + iops: Optional[int] = None, + auto_grow: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + log_on_disk: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + auto_io_scaling: Optional[Union[str, "_models.EnableStatusEnum"]] = None, + storage_redundancy: Union[str, "_models.StorageRedundancyEnum"] = "LocalRedundancy", + **kwargs: Any + ) -> None: + """ + :keyword storage_size_gb: Max storage size allowed for a server. + :paramtype storage_size_gb: int + :keyword iops: Storage IOPS for a server. + :paramtype iops: int + :keyword auto_grow: Enable Storage Auto Grow or not. Known values are: "Enabled" and + "Disabled". + :paramtype auto_grow: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :keyword log_on_disk: Enable Log On Disk or not. Known values are: "Enabled" and "Disabled". + :paramtype log_on_disk: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :keyword auto_io_scaling: Enable IO Auto Scaling or not. Known values are: "Enabled" and + "Disabled". + :paramtype auto_io_scaling: str or ~azure.mgmt.mysqlflexibleservers.models.EnableStatusEnum + :keyword storage_redundancy: The redundant type of the server storage. The parameter is used + for server creation. Known values are: "LocalRedundancy" and "ZoneRedundancy". + :paramtype storage_redundancy: str or + ~azure.mgmt.mysqlflexibleservers.models.StorageRedundancyEnum + """ + super().__init__(**kwargs) + self.storage_size_gb = storage_size_gb + self.iops = iops + self.auto_grow = auto_grow + self.log_on_disk = log_on_disk + self.storage_sku: Optional[str] = None + self.auto_io_scaling = auto_io_scaling + self.storage_redundancy = storage_redundancy + + +class StorageEditionCapability(_serialization.Model): + """storage edition capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: storage edition name. + :vartype name: str + :ivar min_storage_size: The minimal supported storage size. + :vartype min_storage_size: int + :ivar max_storage_size: The maximum supported storage size. + :vartype max_storage_size: int + :ivar min_backup_retention_days: Minimal backup retention days. + :vartype min_backup_retention_days: int + :ivar max_backup_retention_days: Maximum backup retention days. + :vartype max_backup_retention_days: int + :ivar min_backup_interval_hours: Minimal backup interval hours. + :vartype min_backup_interval_hours: int + :ivar max_backup_interval_hours: Maximum backup interval hours. + :vartype max_backup_interval_hours: int + """ + + _validation = { + "name": {"readonly": True}, + "min_storage_size": {"readonly": True}, + "max_storage_size": {"readonly": True}, + "min_backup_retention_days": {"readonly": True}, + "max_backup_retention_days": {"readonly": True}, + "min_backup_interval_hours": {"readonly": True}, + "max_backup_interval_hours": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "min_storage_size": {"key": "minStorageSize", "type": "int"}, + "max_storage_size": {"key": "maxStorageSize", "type": "int"}, + "min_backup_retention_days": {"key": "minBackupRetentionDays", "type": "int"}, + "max_backup_retention_days": {"key": "maxBackupRetentionDays", "type": "int"}, + "min_backup_interval_hours": {"key": "minBackupIntervalHours", "type": "int"}, + "max_backup_interval_hours": {"key": "maxBackupIntervalHours", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.min_storage_size: Optional[int] = None + self.max_storage_size: Optional[int] = None + self.min_backup_retention_days: Optional[int] = None + self.max_backup_retention_days: Optional[int] = None + self.min_backup_interval_hours: Optional[int] = None + self.max_backup_interval_hours: Optional[int] = 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.mysqlflexibleservers.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.mysqlflexibleservers.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.mysqlflexibleservers.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.mysqlflexibleservers.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 UserAssignedIdentity(_serialization.Model): + """Metadata of user assigned identity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: Principal Id of user assigned identity. + :vartype principal_id: str + :ivar client_id: Client Id of user assigned identity. + :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 ValidateBackupResponse(_serialization.Model): + """Represents ValidateBackup API Response. + + :ivar number_of_containers: Estimated no of storage containers required for resource data to be + backed up. + :vartype number_of_containers: int + """ + + _attribute_map = { + "number_of_containers": {"key": "properties.numberOfContainers", "type": "int"}, + } + + def __init__(self, *, number_of_containers: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword number_of_containers: Estimated no of storage containers required for resource data to + be backed up. + :paramtype number_of_containers: int + """ + super().__init__(**kwargs) + self.number_of_containers = number_of_containers + + +class VirtualNetworkSubnetUsageParameter(_serialization.Model): + """Virtual network subnet usage parameter. + + :ivar virtual_network_resource_id: Virtual network resource id. + :vartype virtual_network_resource_id: str + """ + + _attribute_map = { + "virtual_network_resource_id": {"key": "virtualNetworkResourceId", "type": "str"}, + } + + def __init__(self, *, virtual_network_resource_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword virtual_network_resource_id: Virtual network resource id. + :paramtype virtual_network_resource_id: str + """ + super().__init__(**kwargs) + self.virtual_network_resource_id = virtual_network_resource_id + + +class VirtualNetworkSubnetUsageResult(_serialization.Model): + """Virtual network subnet usage data. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: The location name. + :vartype location: str + :ivar subscription_id: The subscription id. + :vartype subscription_id: str + :ivar delegated_subnets_usage: A list of delegated subnet usage. + :vartype delegated_subnets_usage: + list[~azure.mgmt.mysqlflexibleservers.models.DelegatedSubnetUsage] + """ + + _validation = { + "location": {"readonly": True}, + "subscription_id": {"readonly": True}, + "delegated_subnets_usage": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "delegated_subnets_usage": {"key": "delegatedSubnetsUsage", "type": "[DelegatedSubnetUsage]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.subscription_id: Optional[str] = None + self.delegated_subnets_usage: Optional[list["_models.DelegatedSubnetUsage"]] = None diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_enums.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_my_sql_management_client_enums.py similarity index 90% rename from sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_enums.py rename to sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_my_sql_management_client_enums.py index 7457af041ba4..d6cad1b87f23 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_enums.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/models/_my_sql_management_client_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -11,7 +11,7 @@ class AdministratorName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of AdministratorName.""" + """AdministratorName.""" ACTIVE_DIRECTORY = "ActiveDirectory" @@ -23,7 +23,7 @@ class AdministratorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AdvancedThreatProtectionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of AdvancedThreatProtectionName.""" + """AdvancedThreatProtectionName.""" DEFAULT = "Default" @@ -54,7 +54,7 @@ class BackupFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): class BackupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of BackupType.""" + """BackupType.""" FULL = "FULL" @@ -75,16 +75,12 @@ class ConfigurationSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of entity that created the resource.""" + """The type of identity 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): @@ -104,7 +100,7 @@ class DataEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class EnableStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum to indicate whether value is 'Enabled' or 'Disabled'.""" + """Whether or not geo redundant backup is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" @@ -238,24 +234,17 @@ class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsens """The current provisioning state.""" SUCCEEDED = "Succeeded" - """Connection has been provisioned""" CREATING = "Creating" - """Connection is being created""" DELETING = "Deleting" - """Connection is being deleted""" FAILED = "Failed" - """Connection provisioning has failed""" class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status.""" PENDING = "Pending" - """Connection waiting for approval or rejection""" APPROVED = "Approved" - """Connection approved""" REJECTED = "Rejected" - """Connection Rejected""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -317,11 +306,11 @@ class ServerVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): FIVE7 = "5.7" EIGHT0_21 = "8.0.21" - ENUM_8_4 = "8.4" + EIGHT4 = "8.4" class StorageRedundancyEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum to indicate whether storage sku value is 'ZoneRedundancy' or 'LocalRedundancy'.""" + """The redundant type of the server storage. The parameter is used for server creation.""" LOCAL_REDUNDANCY = "LocalRedundancy" ZONE_REDUNDANCY = "ZoneRedundancy" diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/__init__.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/__init__.py index d833fa5e1131..f9cdf4c5b3fd 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/__init__.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/__init__.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,61 +13,61 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._get_private_dns_zone_suffix_operations import GetPrivateDnsZoneSuffixOperations # type: ignore from ._operations import Operations # type: ignore -from ._operations import AzureADAdministratorsOperations # type: ignore -from ._operations import ServersOperations # type: ignore -from ._operations import BackupAndExportOperations # type: ignore -from ._operations import LogFilesOperations # type: ignore -from ._operations import ServersMigrationOperations # type: ignore -from ._operations import BackupsOperations # type: ignore -from ._operations import LongRunningBackupsOperations # type: ignore -from ._operations import LongRunningBackupOperations # type: ignore -from ._operations import ConfigurationsOperations # type: ignore -from ._operations import DatabasesOperations # type: ignore -from ._operations import FirewallRulesOperations # type: ignore -from ._operations import AdvancedThreatProtectionSettingsOperations # type: ignore -from ._operations import LocationBasedCapabilitySetOperations # type: ignore -from ._operations import MaintenancesOperations # type: ignore -from ._operations import PrivateEndpointConnectionsOperations # type: ignore -from ._operations import PrivateLinkResourcesOperations # type: ignore -from ._operations import LocationBasedCapabilitiesOperations # type: ignore -from ._operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore -from ._operations import CheckNameAvailabilityOperations # type: ignore -from ._operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore -from ._operations import OperationResultsOperations # type: ignore -from ._operations import OperationProgressOperations # type: ignore -from ._operations import GetPrivateDnsZoneSuffixOperations # type: ignore -from ._operations import ReplicasOperations # type: ignore +from ._check_name_availability_without_location_operations import CheckNameAvailabilityWithoutLocationOperations # type: ignore +from ._servers_operations import ServersOperations # type: ignore +from ._location_based_capabilities_operations import LocationBasedCapabilitiesOperations # type: ignore +from ._location_based_capability_set_operations import LocationBasedCapabilitySetOperations # type: ignore +from ._check_name_availability_operations import CheckNameAvailabilityOperations # type: ignore +from ._check_virtual_network_subnet_usage_operations import CheckVirtualNetworkSubnetUsageOperations # type: ignore +from ._operation_progress_operations import OperationProgressOperations # type: ignore +from ._operation_results_operations import OperationResultsOperations # type: ignore +from ._azure_ad_administrators_operations import AzureADAdministratorsOperations # type: ignore +from ._advanced_threat_protection_settings_operations import AdvancedThreatProtectionSettingsOperations # type: ignore +from ._backup_and_export_operations import BackupAndExportOperations # type: ignore +from ._backups_operations import BackupsOperations # type: ignore +from ._long_running_backups_operations import LongRunningBackupsOperations # type: ignore +from ._long_running_backup_operations import LongRunningBackupOperations # type: ignore +from ._configurations_operations import ConfigurationsOperations # type: ignore +from ._servers_migration_operations import ServersMigrationOperations # type: ignore +from ._databases_operations import DatabasesOperations # type: ignore +from ._firewall_rules_operations import FirewallRulesOperations # type: ignore +from ._log_files_operations import LogFilesOperations # type: ignore +from ._maintenances_operations import MaintenancesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._replicas_operations import ReplicasOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "GetPrivateDnsZoneSuffixOperations", "Operations", - "AzureADAdministratorsOperations", + "CheckNameAvailabilityWithoutLocationOperations", "ServersOperations", + "LocationBasedCapabilitiesOperations", + "LocationBasedCapabilitySetOperations", + "CheckNameAvailabilityOperations", + "CheckVirtualNetworkSubnetUsageOperations", + "OperationProgressOperations", + "OperationResultsOperations", + "AzureADAdministratorsOperations", + "AdvancedThreatProtectionSettingsOperations", "BackupAndExportOperations", - "LogFilesOperations", - "ServersMigrationOperations", "BackupsOperations", "LongRunningBackupsOperations", "LongRunningBackupOperations", "ConfigurationsOperations", + "ServersMigrationOperations", "DatabasesOperations", "FirewallRulesOperations", - "AdvancedThreatProtectionSettingsOperations", - "LocationBasedCapabilitySetOperations", + "LogFilesOperations", "MaintenancesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", - "LocationBasedCapabilitiesOperations", - "CheckVirtualNetworkSubnetUsageOperations", - "CheckNameAvailabilityOperations", - "CheckNameAvailabilityWithoutLocationOperations", - "OperationResultsOperations", - "OperationProgressOperations", - "GetPrivateDnsZoneSuffixOperations", "ReplicasOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py new file mode 100644 index 000000000000..aa451947c1a0 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_advanced_threat_protection_settings_operations.py @@ -0,0 +1,840 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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(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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.AdvancedThreatProtection"]: + """Gets a list of 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 either AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvancedThreatProtectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AdvancedThreatProtectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.AdvancedThreatProtection: + """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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :return: AdvancedThreatProtection or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdvancedThreatProtection] = 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AdvancedThreatProtection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_put_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, 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", self._config.api_version)) + 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, "AdvancedThreatProtection") + + _request = build_update_put_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, 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 == 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.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_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection + :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_put( + 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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_put( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtection, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is either a + AdvancedThreatProtection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or IO[bytes] + :return: An instance of LROPoller that returns either AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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_put_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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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", self._config.api_version)) + 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, "AdvancedThreatProtectionForUpdate") + + _request = build_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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.AdvancedThreatProtectionForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate + :keyword content_type: Body Parameter 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 AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_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.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Required. + :type parameters: IO[bytes] + :keyword content_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 AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.AdvancedThreatProtectionForUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AdvancedThreatProtection]: + """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName + :param parameters: The server's Advanced Threat Protection body to update. Is either a + AdvancedThreatProtectionForUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or + IO[bytes] + :return: An instance of LROPoller that returns either AdvancedThreatProtection or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + 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("AdvancedThreatProtection", 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.AdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py new file mode 100644 index 000000000000..64876da3f32e --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_azure_ad_administrators_operations.py @@ -0,0 +1,730 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.AzureADAdministrator"]: + """List all the AAD administrators in 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 + :return: An iterator like instance of either AzureADAdministrator or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) + 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, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> _models.AzureADAdministrator: + """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :return: AzureADAdministrator or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AzureADAdministrator] = 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureADAdministrator", 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.AzureADAdministrator, 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", self._config.api_version)) + 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, "AzureADAdministrator") + + _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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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.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, + administrator_name: Union[str, _models.AdministratorName], + parameters: _models.AzureADAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator + :keyword content_type: Body Parameter 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 AzureADAdministrator or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + Required. + :type parameters: IO[bytes] + :keyword content_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 AzureADAdministrator or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :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.AzureADAdministrator, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AzureADAdministrator]: + """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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. Is + either a AzureADAdministrator type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or IO[bytes] + :return: An instance of LROPoller that returns either AzureADAdministrator or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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("AzureADAdministrator", 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.AzureADAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AzureADAdministrator]( + 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", self._config.api_version)) + 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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py new file mode 100644 index 000000000000..9920026ff727 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backup_and_export_operations.py @@ -0,0 +1,403 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/backupAndExport", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/validateBackup", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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.BackupAndExportRequest, 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", self._config.api_version)) + 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, "BackupAndExportRequest") + + _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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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( + self, + resource_group_name: str, + server_name: str, + parameters: _models.BackupAndExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest + :keyword content_type: Body Parameter 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 BackupAndExportResponse or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :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[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Required. + :type parameters: IO[bytes] + :keyword content_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 BackupAndExportResponse or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.BackupAndExportRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupAndExportResponse]: + """Exports the backup of the given server by creating a backup if not existing. + + :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given + server. Is either a BackupAndExportRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or IO[bytes] + :return: An instance of LROPoller that returns either BackupAndExportResponse or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupAndExportResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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): + deserialized = self._deserialize("BackupAndExportResponse", 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.BackupAndExportResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupAndExportResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def validate_backup( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> _models.ValidateBackupResponse: + """Validates if backup can be performed for 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 + :return: ValidateBackupResponse or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) + + _request = build_validate_backup_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ValidateBackupResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_operations.py new file mode 100644 index 000000000000..e015af3a723a --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_backups_operations.py @@ -0,0 +1,376 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.ServerBackup"]: + """List all the backups 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 + :return: An iterator like instance of either ServerBackup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerBackupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, backup_name: str, **kwargs: Any) -> _models.ServerBackup: + """List all the backups 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_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("ServerBackup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def put(self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any) -> _models.ServerBackup: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackup or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) + + _request = build_put_request( + resource_group_name=resource_group_name, + server_name=server_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("ServerBackup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py new file mode 100644 index 000000000000..252f9db9108f --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_operations.py @@ -0,0 +1,210 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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(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-06-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.DBforMySQL/locations/{locationName}/checkNameAvailability", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 CheckNameAvailabilityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, + location_name: str, + name_availability_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def execute( + self, + location_name: str, + name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param location_name: The name of the location. Required. + :type location_name: str + :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or + a IO[bytes] type. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") + + _request = build_execute_request( + location_name=location_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_operations.py new file mode 100644 index 000000000000..14b82b4ff24c --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_name_availability_without_location_operations.py @@ -0,0 +1,192 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/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) + + +class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`check_name_availability_without_location` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + name_availability_request: _models.NameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Required. + :type name_availability_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def execute( + self, name_availability_request: Union[_models.NameAvailabilityRequest, IO[bytes]], **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The request body. Is either a NameAvailabilityRequest type or + a IO[bytes] type. Required. + :type name_availability_request: + ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or IO[bytes] + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NameAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(name_availability_request, (IOBase, bytes)): + _content = name_availability_request + else: + _json = self._serialize.body(name_availability_request, "NameAvailabilityRequest") + + _request = build_execute_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("NameAvailability", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py new file mode 100644 index 000000000000..a9f05b900f1d --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_check_virtual_network_subnet_usage_operations.py @@ -0,0 +1,205 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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(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-06-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.DBforMySQL/locations/{locationName}/checkVirtualNetworkSubnetUsage", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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 CheckVirtualNetworkSubnetUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 execute( + self, + location_name: str, + parameters: _models.VirtualNetworkSubnetUsageParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: VirtualNetworkSubnetUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def execute( + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :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: VirtualNetworkSubnetUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def execute( + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], + **kwargs: Any + ) -> _models.VirtualNetworkSubnetUsageResult: + """Get virtual network subnet usage for a given vNet resource id. + + :param location_name: The name of the location. Required. + :type location_name: str + :param parameters: The request body. Is either a VirtualNetworkSubnetUsageParameter type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or + IO[bytes] + :return: VirtualNetworkSubnetUsageResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") + + _request = build_execute_request( + location_name=location_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualNetworkSubnetUsageResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py new file mode 100644 index 000000000000..217e2ab3f064 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_configurations_operations.py @@ -0,0 +1,1075 @@ +# 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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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, + *, + tags: Optional[str] = None, + keyword: Optional[str] = None, + page: Optional[int] = None, + page_size: 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/updateConfigurations", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, + tags: Optional[str] = None, + keyword: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.Configuration"]: + """List all the configurations in 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 tags: The tags of the server configuration. Default value is None. + :type tags: str + :param keyword: The keyword of the server configuration. Default value is None. + :type keyword: str + :param page: The page of the server configuration. Default value is None. + :type page: int + :param page_size: The pageSize of the server configuration. Default value is None. + :type page_size: int + :return: An iterator like instance of either Configuration or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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, + tags=tags, + keyword=keyword, + page=page, + page_size=page_size, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, configuration_name: str, **kwargs: Any + ) -> _models.Configuration: + """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :return: Configuration or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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("Configuration", 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, + configuration_name: str, + parameters: Union[_models.Configuration, 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", self._config.api_version)) + 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, "Configuration") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter 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 Configuration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is either a + Configuration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] + :return: An instance of LROPoller that returns either Configuration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, 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", self._config.api_version)) + 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, "Configuration") + + _request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + configuration_name=configuration_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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + configuration_name: str, + parameters: _models.Configuration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration + :keyword content_type: Body Parameter 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 Configuration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 Configuration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + configuration_name: str, + parameters: Union[_models.Configuration, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Configuration]: + """Updates a configuration 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 + :param configuration_name: The name of the server configuration. Required. + :type configuration_name: str + :param parameters: The required parameters for updating a server configuration. Is either a + Configuration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or IO[bytes] + :return: An instance of LROPoller that returns either Configuration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + configuration_name=configuration_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("Configuration", 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.Configuration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _batch_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, 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", self._config.api_version)) + 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, "ConfigurationListForBatchUpdate") + + _request = build_batch_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ConfigurationListForBatchUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate + :keyword content_type: Body Parameter 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 ConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. + :type parameters: IO[bytes] + :keyword content_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 ConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_batch_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ConfigurationListForBatchUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationListResult]: + """Update a list of configurations in 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 parameters for updating a list of server configuration. Is either a + ConfigurationListForBatchUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or + IO[bytes] + :return: An instance of LROPoller that returns either ConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationListResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._batch_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("ConfigurationListResult", 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.ConfigurationListResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ConfigurationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py new file mode 100644 index 000000000000..08be298baae2 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_databases_operations.py @@ -0,0 +1,694 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/databases", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/databases/{databaseName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/databases/{databaseName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/databases/{databaseName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Database"]: + """List all the databases in 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 + :return: An iterator like instance of either Database or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) + 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, **kwargs: Any) -> _models.Database: + """Gets information about 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: Database or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + 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("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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_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.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, + 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 required parameters for creating or updating a database. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: 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 required parameters for creating or updating a database. Is either a + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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": "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 _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", self._config.api_version)) + 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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, database_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + 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 diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py new file mode 100644 index 000000000000..f8e3810eaa6b --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_firewall_rules_operations.py @@ -0,0 +1,705 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/firewallRules", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.FirewallRule"]: + """List all the firewall rules in 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 + :return: An iterator like instance of either FirewallRule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) + 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, firewall_rule_name: str, **kwargs: Any + ) -> _models.FirewallRule: + """Gets information about a server 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 server firewall rule. Required. + :type firewall_rule_name: str + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FirewallRule", 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, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, 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", self._config.api_version)) + 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, "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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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 == 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.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, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of LROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_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 + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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: An instance of LROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.FirewallRule]: + """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or IO[bytes] + :return: An instance of LROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + firewall_rule_name=firewall_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("FirewallRule", 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.FirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, firewall_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", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = 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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, firewall_rule_name: str, **kwargs: Any + ) -> LROPoller[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 server firewall rule. Required. + :type firewall_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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py new file mode 100644 index 000000000000..05ad4a60659c --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_get_private_dns_zone_suffix_operations.py @@ -0,0 +1,125 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix") + + # 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 GetPrivateDnsZoneSuffixOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: + """Get private DNS zone suffix in the cloud. + + :return: GetPrivateDnsZoneSuffixResponse or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) + + _request = build_execute_request( + 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("GetPrivateDnsZoneSuffixResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py new file mode 100644 index 000000000000..b25cf3d298f1 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capabilities_operations.py @@ -0,0 +1,168 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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(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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilities", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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 LocationBasedCapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> ItemPaged["_models.CapabilityProperties"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of either CapabilityProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CapabilitiesListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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( + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CapabilitiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py new file mode 100644 index 000000000000..2b8f83856935 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_location_based_capability_set_operations.py @@ -0,0 +1,258 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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(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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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, subscription_id: str, capability_set_name: str = "default", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets/{capabilitySetName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), + "capabilitySetName": _SERIALIZER.url( + "capability_set_name", capability_set_name, "str", pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :return: An iterator like instance of either Capability or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CapabilitySetsList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: 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( + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CapabilitySetsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, capability_set_name: str = "default", **kwargs: Any) -> _models.Capability: + """Get capabilities at specified location in a given subscription. + + :param location_name: The name of the location. Required. + :type location_name: str + :param capability_set_name: Name of capability set. Default value is "default". + :type capability_set_name: str + :return: Capability or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Capability] = kwargs.pop("cls", None) + + _request = build_get_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + capability_set_name=capability_set_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Capability", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py new file mode 100644 index 000000000000..c59340044a5a --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_log_files_operations.py @@ -0,0 +1,178 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/logFiles", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: + """List all the server log files in 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 + :return: An iterator like instance of either LogFile or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LogFileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LogFileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py new file mode 100644 index 000000000000..2697fb80feca --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backup_operations.py @@ -0,0 +1,481 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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, 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-06-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.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ServerBackupV2") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + server_name=server_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, 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 == 201: + 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.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( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[_models.ServerBackupV2] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :keyword content_type: Body Parameter 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 ServerBackupV2 or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Default value is None. + :type parameters: IO[bytes] + :keyword content_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 ServerBackupV2 or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + backup_name: str, + parameters: Optional[Union[_models.ServerBackupV2, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.ServerBackupV2]: + """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :param parameters: The required parameters for creating and exporting backup of the given + server. Is either a ServerBackupV2 type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or IO[bytes] + :return: An instance of LROPoller that returns either ServerBackupV2 or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + 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("ServerBackupV2", 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.ServerBackupV2].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerBackupV2]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_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", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_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 [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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, backup_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete backup for a given server with specified backup 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 backup_name: The name of the backup. 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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_operations.py new file mode 100644 index 000000000000..ad8b7a5032a7 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_long_running_backups_operations.py @@ -0,0 +1,276 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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(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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.ServerBackupV2"]: + """List all the backups 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 + :return: An iterator like instance of either ServerBackupV2 or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackupV2ListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerBackupV2ListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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, backup_name: str, **kwargs: Any + ) -> _models.ServerBackupV2: + """Get backup 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 backup_name: The name of the backup. Required. + :type backup_name: str + :return: ServerBackupV2 or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_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("ServerBackupV2", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py new file mode 100644 index 000000000000..dc2fab364560 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_maintenances_operations.py @@ -0,0 +1,542 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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(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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Maintenance"]: + """List maintenances. + + :param resource_group_name: The name of the resource group. 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 either Maintenance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.MaintenanceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MaintenanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_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 read( + self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any + ) -> _models.Maintenance: + """Read maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :return: Maintenance or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + + _request = build_read_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_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("Maintenance", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "MaintenanceUpdate") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + maintenance_name=maintenance_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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + maintenance_name: str, + parameters: Optional[_models.MaintenanceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate + :keyword content_type: Body Parameter 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 Maintenance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Default value is + None. + :type parameters: IO[bytes] + :keyword content_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 Maintenance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + maintenance_name: str, + parameters: Optional[Union[_models.MaintenanceUpdate, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.Maintenance]: + """Update maintenances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param maintenance_name: The name of the maintenance. Required. + :type maintenance_name: str + :param parameters: The required parameters for update maintenance on a server. Is either a + MaintenanceUpdate type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or IO[bytes] + :return: An instance of LROPoller that returns either Maintenance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, + maintenance_name=maintenance_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("Maintenance", 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.Maintenance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Maintenance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py new file mode 100644 index 000000000000..3247832b1611 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_progress_operations.py @@ -0,0 +1,145 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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, 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationProgress/{operationId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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 OperationProgressOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationProgressResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) + + _request = build_get_request( + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationProgressResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py new file mode 100644 index 000000000000..4570b009747c --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operation_results_operations.py @@ -0,0 +1,145 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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, 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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationResults/{operationId}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str", min_length=1, pattern=r"^[ \w]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_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 OperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s + :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: + """Get the operation result for a long running operation. + + Get the operation result for a long running operation. + + :param location_name: The name of the location. Required. + :type location_name: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusExtendedResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) + + _request = build_get_request( + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusExtendedResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py index eb6cfa8c79cd..76e2afb01216 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_operations.py @@ -1,15 +1,12 @@ -# 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. +# Code generated by Microsoft (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 -import json -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Optional, TypeVar import urllib.parse from azure.core import PipelineClient @@ -19,35 +16,28 @@ 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 MySQLManagementClientConfiguration -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_operations_list_request(**kwargs: Any) -> HttpRequest: +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -55,7 +45,7 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/providers/Microsoft.DBforMySQL/operations" + _url = kwargs.pop("template_url", "/providers/Microsoft.DBforMySQL/operations") # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -66,11120 +56,17 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_servers_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", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_servers_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers" - 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_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/flexibleServers" - 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_servers_failover_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/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"), - } - - _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_servers_validate_estimate_high_availability_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/validateEstimateHighAvailability" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_restart_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/restart" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_servers_start_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/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"), - } - - _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_servers_stop_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/stop" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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="POST", url=_url, params=_params, **kwargs) - - -def build_servers_reset_gtid_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/resetGtid" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_servers_detach_v_net_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/detachVNet" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_backup_and_export_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupAndExport" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_backup_and_export_validate_backup_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/validateBackup" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_log_files_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/logFiles" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_migration_cutover_migration_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/cutoverMigration" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_backups_get_request( - resource_group_name: str, server_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_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_backups_put_request( - resource_group_name: str, server_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_backups_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_long_running_backups_get_request( - resource_group_name: str, server_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_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_running_backups_list_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_long_running_backup_create_request( - resource_group_name: str, server_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_long_running_backup_delete_request( - resource_group_name: str, server_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupsV2/{backupName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_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_configurations_get_request( - resource_group_name: str, server_name: str, configuration_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_configurations_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, server_name: str, configuration_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.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_configurations_update_request( - resource_group_name: str, server_name: str, configuration_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_configurations_list_by_server_request( # pylint: disable=name-too-long - resource_group_name: str, - server_name: str, - subscription_id: str, - *, - tags: Optional[str] = None, - keyword: Optional[str] = None, - page: Optional[int] = None, - page_size: 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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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 tags is not None: - _params["tags"] = _SERIALIZER.query("tags", tags, "str") - if keyword is not None: - _params["keyword"] = _SERIALIZER.query("keyword", keyword, "str") - if page is not None: - _params["page"] = _SERIALIZER.query("page", page, "int") - if page_size is not None: - _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_configurations_batch_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/updateConfigurations" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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_databases_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", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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 - _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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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") - - # 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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_advanced_threat_protection_settings_update_put_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_advanced_threat_protection_settings_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_advanced_threat_protection_settings_list_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_location_based_capability_set_get_request( # pylint: disable=name-too-long - location_name: str, capability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets/{capabilitySetName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "capabilitySetName": _SERIALIZER.url("capability_set_name", capability_set_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_location_based_capability_set_list_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/capabilitySets" - 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_maintenances_read_request( - resource_group_name: str, server_name: str, maintenance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "maintenanceName": _SERIALIZER.url("maintenance_name", maintenance_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_maintenances_update_request( - resource_group_name: str, server_name: str, maintenance_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances/{maintenanceName}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "maintenanceName": _SERIALIZER.url("maintenance_name", maintenance_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_maintenances_list_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/maintenances" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{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_location_based_capabilities_list_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_virtual_network_subnet_usage_execute_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 {}) - - 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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/checkVirtualNetworkSubnetUsage" - 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 - if content_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_check_name_availability_execute_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 {}) - - 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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = ( - "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/checkNameAvailability" - ) - 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 - if content_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_check_name_availability_without_location_execute_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/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_operation_results_get_request( - 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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationResults/{operationId}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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_operation_progress_get_request( - 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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/locations/{locationName}/operationProgress/{operationId}" - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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_get_private_dns_zone_suffix_execute_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix" - - # 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_replicas_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-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/replicas" - path_format_arguments = { - "subscriptionId": _SERIALIZER.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 Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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"]: - """List the operations for the provider. - - :return: An iterator like instance of Operation - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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 AzureADAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.AzureADAdministrator: - """Gets information about an azure ad 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :return: AzureADAdministrator. The AzureADAdministrator is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.AzureADAdministrator] = kwargs.pop("cls", None) - - _request = build_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) - - _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() - else: - deserialized = _deserialize(_models.AzureADAdministrator, 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.AzureADAdministrator, 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_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) - - _stream = True - pipeline_response: PipelineResponse = 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 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.AzureADAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns AzureADAdministrator. The AzureADAdministrator - is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: 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 AzureADAdministrator. The AzureADAdministrator - is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. - Required. - :type parameters: IO[bytes] - :keyword content_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 AzureADAdministrator. The AzureADAdministrator - is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AzureADAdministrator]: - """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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.models.AdministratorName - :param parameters: The required parameters for creating or updating an aad administrator. Is - one of the following types: AzureADAdministrator, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator or JSON or - IO[bytes] - :return: An instance of LROPoller that returns AzureADAdministrator. The AzureADAdministrator - is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :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.AzureADAdministrator] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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.AzureADAdministrator, 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.AzureADAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AzureADAdministrator]( - 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_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) - - _stream = True - pipeline_response: PipelineResponse = self._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 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 an Azure AD 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 the Azure AD Administrator. "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.mysqlflexibleservers.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.AzureADAdministrator"]: - """List all the AAD administrators in 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 - :return: An iterator like instance of AzureADAdministrator - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.AzureADAdministrator]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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.AzureADAdministrator], 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: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Server: - """Gets information about 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: Server. The Server is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Server, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_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_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) - - _stream = True - pipeline_response: PipelineResponse = 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 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.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] - :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[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: 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.mysqlflexibleservers.models.Server] - :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[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.Server, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates a new server or updates an existing server. The update action will overwrite the - existing 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 required parameters for creating or updating a server. Is one of the - following types: Server, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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_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.ServerForUpdate, 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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 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.ServerForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate - :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerForUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates an existing server. The request body can contain one to many of the properties present - in the normal server definition. - - :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is one of the following - types: ServerForUpdate, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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) - - _stream = True - pipeline_response: PipelineResponse = self._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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.iter_bytes() - - 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, **kwargs: Any) -> ItemPaged["_models.Server"]: - """List all the servers in a given 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 Server - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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, **kwargs: Any) -> ItemPaged["_models.Server"]: - """List all the servers in a given subscription. - - :return: An iterator like instance of Server - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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 _failover_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_failover_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 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, **kwargs: Any) -> LROPoller[None]: - """Manual failover 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._failover_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 - - @overload - def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: _models.HighAvailabilityValidationEstimation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_estimate_high_availability( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.HighAvailabilityValidationEstimation, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.HighAvailabilityValidationEstimation: - """Validate a deployment of high availability. - - :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is - one of the following types: HighAvailabilityValidationEstimation, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - or JSON or IO[bytes] - :return: HighAvailabilityValidationEstimation. The HighAvailabilityValidationEstimation is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation - :raises ~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.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) - - content_type = content_type or "application/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_validate_estimate_high_availability_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) - - _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() - else: - deserialized = _deserialize(_models.HighAvailabilityValidationEstimation, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _restart_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, 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_restart_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_restart( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerRestartParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter - :keyword content_type: Body Parameter 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: 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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts 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 required parameters for restarting a server. Required. - :type parameters: IO[bytes] - :keyword content_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_restart( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerRestartParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Restarts 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 required parameters for restarting a server. Is one of the following - types: ServerRestartParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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._restart_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 - - def _start_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_start_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Starts 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._start_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 - - def _stop_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_stop_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Stops 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._stop_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 - - def _reset_gtid_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, 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_reset_gtid_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerGtidSetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter - :keyword content_type: Body Parameter 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: 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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Required. - :type parameters: IO[bytes] - :keyword content_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_reset_gtid( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerGtidSetParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Resets GTID 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 - :param parameters: The required parameters for resetting GTID on a server. Is one of the - following types: ServerGtidSetParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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._reset_gtid_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 - - def _detach_v_net_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, 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_detach_v_net_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerDetachVNetParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter - :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: 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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Required. - :type parameters: IO[bytes] - :keyword content_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.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_detach_v_net( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerDetachVNetParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Detach VNet 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 - :param parameters: The required parameters for detach vnet on a server. Is one of the following - types: ServerDetachVNetParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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._detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = _deserialize(_models.Server, 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.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 - ) - - -class BackupAndExportOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`backup_and_export` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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.BackupAndExportRequest, 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_and_export_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 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.BackupAndExportRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: 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 BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Required. - :type parameters: IO[bytes] - :keyword content_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 BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.BackupAndExportRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.BackupAndExportResponse]: - """Exports the backup of the given server by creating a backup if not existing. - - :param resource_group_name: The name of the resource group. The 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 required parameters for creating and exporting backup of the given - server. Is one of the following types: BackupAndExportRequest, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.BackupAndExportRequest or JSON or - IO[bytes] - :return: An instance of LROPoller that returns BackupAndExportResponse. The - BackupAndExportResponse is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.BackupAndExportResponse] - :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.BackupAndExportResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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): - 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.BackupAndExportResponse, 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.BackupAndExportResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.BackupAndExportResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def validate_backup( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> _models.ValidateBackupResponse: - """Validates if backup can be performed for 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 - :return: ValidateBackupResponse. The ValidateBackupResponse is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ValidateBackupResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ValidateBackupResponse] = kwargs.pop("cls", None) - - _request = build_backup_and_export_validate_backup_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) - - _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() - else: - deserialized = _deserialize(_models.ValidateBackupResponse, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class LogFilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`log_files` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.LogFile"]: - """List all the server log files in 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 - :return: An iterator like instance of LogFile - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.LogFile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.LogFile]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_log_files_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.LogFile], 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 ServersMigrationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`servers_migration` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 _cutover_migration_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_migration_cutover_migration_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_cutover_migration( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> LROPoller[_models.Server]: - """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible - 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 Server. The Server is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - 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._cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = _deserialize(_models.Server, 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.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 - ) - - -class BackupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, backup_name: str, **kwargs: Any) -> _models.ServerBackup: - """List all the backups 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup. The ServerBackup is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_backups_get_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _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() - else: - deserialized = _deserialize(_models.ServerBackup, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def put(self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any) -> _models.ServerBackup: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackup. The ServerBackup is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - - _request = build_backups_put_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _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() - else: - deserialized = _deserialize(_models.ServerBackup, 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.ServerBackup"]: - """List all the backups 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 - :return: An iterator like instance of ServerBackup - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.ServerBackup]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_backups_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.ServerBackup], 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 LongRunningBackupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`long_running_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, backup_name: str, **kwargs: Any - ) -> _models.ServerBackupV2: - """Get backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :return: ServerBackupV2. The ServerBackupV2 is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - - _request = build_long_running_backups_get_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _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() - else: - deserialized = _deserialize(_models.ServerBackupV2, 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, **kwargs: Any) -> ItemPaged["_models.ServerBackupV2"]: - """List all the backups 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 - :return: An iterator like instance of ServerBackupV2 - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.ServerBackupV2]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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_running_backups_list_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.ServerBackupV2], 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 LongRunningBackupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`long_running_backup` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None - - _request = build_long_running_backup_create_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _stream = True - pipeline_response: PipelineResponse = 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["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 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, - backup_name: str, - parameters: Optional[_models.ServerBackupV2] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns ServerBackupV2. The ServerBackupV2 is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: 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 ServerBackupV2. The ServerBackupV2 is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Default value is None. - :type parameters: IO[bytes] - :keyword content_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 ServerBackupV2. The ServerBackupV2 is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - backup_name: str, - parameters: Optional[Union[_models.ServerBackupV2, JSON, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.ServerBackupV2]: - """Create backup for a given server with specified backup 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 backup_name: The name of the backup. Required. - :type backup_name: str - :param parameters: The required parameters for creating and exporting backup of the given - server. Is one of the following types: ServerBackupV2, JSON, IO[bytes] Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2 or JSON or IO[bytes] - :return: An instance of LROPoller that returns ServerBackupV2. The ServerBackupV2 is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ServerBackupV2] - :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)) - content_type = content_type if parameters else None - cls: ClsType[_models.ServerBackupV2] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - 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.ServerBackupV2, 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.ServerBackupV2].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerBackupV2]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @api_version_validation( - method_added_on="2025-06-01-preview", - params_added_on={ - "2025-06-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "server_name", - "backup_name", - ] - }, - api_versions_list=["2025-06-01-preview"], - ) - def _delete_initial( - self, resource_group_name: str, server_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_running_backup_delete_request( - resource_group_name=resource_group_name, - server_name=server_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - @api_version_validation( - method_added_on="2025-06-01-preview", - params_added_on={ - "2025-06-01-preview": [ - "api_version", - "subscription_id", - "resource_group_name", - "server_name", - "backup_name", - ] - }, - api_versions_list=["2025-06-01-preview"], - ) - def begin_delete( - self, resource_group_name: str, server_name: str, backup_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete backup for a given server with specified backup 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 backup_name: The name of the backup. 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( - resource_group_name=resource_group_name, - server_name=server_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 - - -class ConfigurationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, configuration_name: str, **kwargs: Any - ) -> _models.Configuration: - """Gets information about a configuration of 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 configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :return: Configuration. The Configuration is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - - _request = build_configurations_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Configuration, 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, - configuration_name: str, - parameters: Union[_models.Configuration, 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_configurations_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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 = True - pipeline_response: PipelineResponse = self._client._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 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: 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 Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is one of the - following types: Configuration, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] - :return: An instance of LROPoller that returns Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :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.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Configuration]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, 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_configurations_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - configuration_name=configuration_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 = True - pipeline_response: PipelineResponse = self._client._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 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, - configuration_name: str, - parameters: _models.Configuration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: 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 Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - configuration_name: str, - parameters: Union[_models.Configuration, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Configuration]: - """Updates a configuration 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 - :param configuration_name: The name of the server configuration. Required. - :type configuration_name: str - :param parameters: The required parameters for updating a server configuration. Is one of the - following types: Configuration, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.Configuration or JSON or IO[bytes] - :return: An instance of LROPoller that returns Configuration. The Configuration is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :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.Configuration] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - configuration_name=configuration_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.Configuration, 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.Configuration].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Configuration]( - 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, - *, - tags: Optional[str] = None, - keyword: Optional[str] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.Configuration"]: - """List all the configurations in 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 - :keyword tags: The tags of the server configuration. Default value is None. - :paramtype tags: str - :keyword keyword: The keyword of the server configuration. Default value is None. - :paramtype keyword: str - :keyword page: The page of the server configuration. Default value is None. - :paramtype page: int - :keyword page_size: The pageSize of the server configuration. Default value is None. - :paramtype page_size: int - :return: An iterator like instance of Configuration - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Configuration] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Configuration]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_configurations_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - tags=tags, - keyword=keyword, - page=page, - page_size=page_size, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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.Configuration], 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 _batch_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, 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_configurations_batch_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ConfigurationListForBatchUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: 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 ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Required. - :type parameters: IO[bytes] - :keyword content_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 ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_batch_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ConfigurationListForBatchUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ConfigurationListResult]: - """Update a list of configurations in 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 parameters for updating a list of server configuration. Is one of the - following types: ConfigurationListForBatchUpdate, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ConfigurationListForBatchUpdate or - JSON or IO[bytes] - :return: An instance of LROPoller that returns ConfigurationListResult. The - ConfigurationListResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.ConfigurationListResult] - :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.ConfigurationListResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._batch_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.ConfigurationListResult, 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.ConfigurationListResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConfigurationListResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class DatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.Database: - """Gets information about 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: Database. The Database is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - 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) - - _stream = True - pipeline_response: PipelineResponse = 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 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 required parameters for creating or updating a database. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a 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 Database. The Database is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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 required parameters for creating or updating a database. Is one of the - following types: Database, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 _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) - - _stream = True - pipeline_response: PipelineResponse = self._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 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 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 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 - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.Database"]: - """List all the databases in 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 - :return: An iterator like instance of Database - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._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.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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 information about a server 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 server firewall rule. Required. - :type firewall_rule_name: str - :return: FirewallRule. The FirewallRule is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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) - - _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() - else: - deserialized = _deserialize(_models.FirewallRule, 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, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, 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_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) - - _stream = True - pipeline_response: PipelineResponse = 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 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, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.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: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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 - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.FirewallRule]: - """Creates a new firewall rule or updates an existing 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 server 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.mysqlflexibleservers.models.FirewallRule or JSON or IO[bytes] - :return: An instance of LROPoller that returns FirewallRule. The FirewallRule is compatible - with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.FirewallRule] - :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.FirewallRule] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - firewall_rule_name=firewall_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.FirewallRule, 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.FirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, firewall_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_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 = True - pipeline_response: PipelineResponse = self._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 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, firewall_rule_name: str, **kwargs: Any - ) -> LROPoller[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 server firewall rule. Required. - :type firewall_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, - firewall_rule_name=firewall_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.FirewallRule"]: - """List all the firewall rules in 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 - :return: An iterator like instance of FirewallRule - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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) - - -class AdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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.AdvancedThreatProtection: - """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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :return: AdvancedThreatProtection. The AdvancedThreatProtection is compatible with - MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.AdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_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) - - _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() - else: - deserialized = _deserialize(_models.AdvancedThreatProtection, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_put_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, 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_advanced_threat_protection_settings_update_put_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) - - _stream = True - pipeline_response: PipelineResponse = 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 cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_put( - 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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: 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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_put( - 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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_put( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtection, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is one of the - following types: AdvancedThreatProtection, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection or JSON or - IO[bytes] - :return: An instance of LROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :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.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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_put_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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, 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_advanced_threat_protection_settings_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) - - _stream = True - pipeline_response: PipelineResponse = self._client._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 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, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.AdvancedThreatProtectionForUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: 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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Required. - :type parameters: IO[bytes] - :keyword content_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 AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.AdvancedThreatProtectionForUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AdvancedThreatProtection]: - """Updates 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.mysqlflexibleservers.models.AdvancedThreatProtectionName - :param parameters: The server's Advanced Threat Protection body to update. Is one of the - following types: AdvancedThreatProtectionForUpdate, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtectionForUpdate or - JSON or IO[bytes] - :return: An instance of LROPoller that returns AdvancedThreatProtection. The - AdvancedThreatProtection is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :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.AdvancedThreatProtection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - 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.AdvancedThreatProtection, 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.AdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.AdvancedThreatProtection"]: - """Gets a list of 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 AdvancedThreatProtection - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.AdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.AdvancedThreatProtection]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_advanced_threat_protection_settings_list_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.AdvancedThreatProtection], 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 LocationBasedCapabilitySetOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`location_based_capability_set` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, capability_set_name: str, **kwargs: Any) -> _models.Capability: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :param capability_set_name: Name of capability set. Required. - :type capability_set_name: str - :return: Capability. The Capability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Capability] = kwargs.pop("cls", None) - - _request = build_location_based_capability_set_get_request( - location_name=location_name, - capability_set_name=capability_set_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Capability, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.Capability"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of Capability - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Capability] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Capability]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_location_based_capability_set_list_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.Capability], 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 MaintenancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`maintenances` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def read( - self, resource_group_name: str, server_name: str, maintenance_name: str, **kwargs: Any - ) -> _models.Maintenance: - """Read maintenance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :return: Maintenance. The Maintenance is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.Maintenance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - - _request = build_maintenances_read_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_name, - subscription_id=self._config.subscription_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.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 = 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() - else: - deserialized = _deserialize(_models.Maintenance, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - content_type = content_type if parameters else None - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" if parameters else None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - else: - _content = None - - _request = build_maintenances_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - maintenance_name=maintenance_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 = True - pipeline_response: PipelineResponse = self._client._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 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, - maintenance_name: str, - parameters: Optional[_models.MaintenanceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns Maintenance. The Maintenance is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[JSON] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: 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 Maintenance. The Maintenance is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Default value is - None. - :type parameters: IO[bytes] - :keyword content_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 Maintenance. The Maintenance is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - maintenance_name: str, - parameters: Optional[Union[_models.MaintenanceUpdate, JSON, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.Maintenance]: - """Update maintenances. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param maintenance_name: The name of the maintenance. Required. - :type maintenance_name: str - :param parameters: The required parameters for update maintenance on a server. Is one of the - following types: MaintenanceUpdate, JSON, IO[bytes] Default value is None. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.MaintenanceUpdate or JSON or - IO[bytes] - :return: An instance of LROPoller that returns Maintenance. The Maintenance is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :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)) - content_type = content_type if parameters else None - cls: ClsType[_models.Maintenance] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - maintenance_name=maintenance_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.Maintenance, 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.Maintenance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Maintenance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list(self, resource_group_name: str, server_name: str, **kwargs: Any) -> ItemPaged["_models.Maintenance"]: - """List maintenances. - - :param resource_group_name: The name of the resource group. 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 Maintenance - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Maintenance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Maintenance]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_maintenances_list_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.Maintenance], 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.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with - MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.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) - - _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() - 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) - - _stream = True - pipeline_response: PipelineResponse = 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["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 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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create 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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create 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.mysqlflexibleservers.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 associated - with the Azure resource. Required. - :type private_endpoint_connection_name: str - :param parameters: Resource create parameters. Is one of the following types: - PrivateEndpointConnection, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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) - - _stream = True - pipeline_response: PipelineResponse = self._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 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 associated - with the Azure resource. 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 - ) -> _models.PrivateEndpointConnectionListResult: - """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: PrivateEndpointConnectionListResult. The PrivateEndpointConnectionListResult is - compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - _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) - - _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() - else: - deserialized = _deserialize(_models.PrivateEndpointConnectionListResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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 MySQL 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.mysqlflexibleservers.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) - - _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() - 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"]: - """Lists the private link resources for MySQL 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.mysqlflexibleservers.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 None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=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 LocationBasedCapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`location_based_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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, location_name: str, **kwargs: Any) -> ItemPaged["_models.CapabilityProperties"]: - """Get capabilities at specified location in a given subscription. - - :param location_name: The name of the location. Required. - :type location_name: str - :return: An iterator like instance of CapabilityProperties - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.CapabilityProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.CapabilityProperties]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_location_based_capabilities_list_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.CapabilityProperties], 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 CheckVirtualNetworkSubnetUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`check_virtual_network_subnet_usage` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - parameters: _models.VirtualNetworkSubnetUsageParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, location_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :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: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def execute( - self, - location_name: str, - parameters: Union[_models.VirtualNetworkSubnetUsageParameter, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.VirtualNetworkSubnetUsageResult: - """Get virtual network subnet usage for a given vNet resource id. - - :param location_name: The name of the location. Required. - :type location_name: str - :param parameters: The request body. Is one of the following types: - VirtualNetworkSubnetUsageParameter, JSON, IO[bytes] Required. - :type parameters: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageParameter or - JSON or IO[bytes] - :return: VirtualNetworkSubnetUsageResult. The VirtualNetworkSubnetUsageResult is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.VirtualNetworkSubnetUsageResult - :raises ~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.VirtualNetworkSubnetUsageResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_check_virtual_network_subnet_usage_execute_request( - location_name=location_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 = 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() - else: - deserialized = _deserialize(_models.VirtualNetworkSubnetUsageResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CheckNameAvailabilityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`check_name_availability` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - location_name: str, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, - location_name: str, - name_availability_request: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, - location_name: str, - name_availability_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def execute( - self, - location_name: str, - name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param location_name: The name of the location. Required. - :type location_name: str - :param name_availability_request: The request body. Is one of the following types: - NameAvailabilityRequest, JSON, IO[bytes] Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_check_name_availability_execute_request( - location_name=location_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 = 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() - else: - deserialized = _deserialize(_models.NameAvailability, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CheckNameAvailabilityWithoutLocationOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`check_name_availability_without_location` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_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 execute( - self, - name_availability_request: _models.NameAvailabilityRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, name_availability_request: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def execute( - self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Required. - :type name_availability_request: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def execute( - self, name_availability_request: Union[_models.NameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any - ) -> _models.NameAvailability: - """Check the availability of name for server. - - :param name_availability_request: The request body. Is one of the following types: - NameAvailabilityRequest, JSON, IO[bytes] Required. - :type name_availability_request: - ~azure.mgmt.mysqlflexibleservers.models.NameAvailabilityRequest or JSON or IO[bytes] - :return: NameAvailability. The NameAvailability is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.NameAvailability - :raises ~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.NameAvailability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(name_availability_request, (IOBase, bytes)): - _content = name_availability_request - else: - _content = json.dumps(name_availability_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_check_name_availability_without_location_execute_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) - - _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() - else: - deserialized = _deserialize(_models.NameAvailability, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class OperationResultsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`operation_results` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationStatusExtendedResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationStatusExtendedResult. The OperationStatusExtendedResult is compatible with - MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationStatusExtendedResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.OperationStatusExtendedResult] = kwargs.pop("cls", None) - - _request = build_operation_results_get_request( - 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) - - _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() - else: - deserialized = _deserialize(_models.OperationStatusExtendedResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class OperationProgressOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`operation_progress` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) 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, operation_id: str, **kwargs: Any) -> _models.OperationProgressResult: - """Get the operation result for a long running operation. - - Get the operation result for a long running operation. - - :param location_name: The name of the location. Required. - :type location_name: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationProgressResult. The OperationProgressResult is compatible with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.OperationProgressResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.OperationProgressResult] = kwargs.pop("cls", None) - - _request = build_operation_progress_get_request( - 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) - - _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() - else: - deserialized = _deserialize(_models.OperationProgressResult, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class GetPrivateDnsZoneSuffixOperations: +class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`get_private_dns_zone_suffix` 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: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def execute(self, **kwargs: Any) -> _models.GetPrivateDnsZoneSuffixResponse: - """Get private DNS zone suffix in the cloud. - - :return: GetPrivateDnsZoneSuffixResponse. The GetPrivateDnsZoneSuffixResponse is compatible - with MutableMapping - :rtype: ~azure.mgmt.mysqlflexibleservers.models.GetPrivateDnsZoneSuffixResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.GetPrivateDnsZoneSuffixResponse] = kwargs.pop("cls", None) - - _request = build_get_private_dns_zone_suffix_execute_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) - - _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() - else: - deserialized = _deserialize(_models.GetPrivateDnsZoneSuffixResponse, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class ReplicasOperations: + :attr:`operations` attribute. """ - .. warning:: - **DO NOT** instantiate this class directly. - Instead, you should access the following operations through - :class:`~azure.mgmt.mysqlflexibleservers.MySQLManagementClient`'s - :attr:`replicas` attribute. - """ + models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) @@ -11189,22 +76,18 @@ def __init__(self, *args, **kwargs) -> None: 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.Server"]: - """List all the replicas for a given server. + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """List the operations for the 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 - :return: An iterator like instance of Server - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Server] + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11217,20 +100,12 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A def prepare_request(next_link=None): if not next_link: - _request = build_replicas_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, + _request = build_list_request( + api_version=api_version, headers=_headers, params=_params, ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -11245,21 +120,16 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.base_url", self._config.base_url, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - + _request.url = self._client.format_url(_request.url) + _request.method = "GET" return _request def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Server], deserialized.get("value", [])) + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -11272,9 +142,9 @@ 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) - error = _failsafe_deserialize( + error = self._deserialize.failsafe_deserialize( _models.ErrorResponse, - response, + pipeline_response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..1ea8ad7cc462 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,697 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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 + ) -> _models.PrivateEndpointConnectionListResult: + """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: PrivateEndpointConnectionListResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateEndpointConnectionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + _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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_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("PrivateEndpointConnectionListResult", 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, 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, 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", self._config.api_version)) + 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, 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 == 201: + 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.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, + 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create 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.mysqlflexibleservers.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. The 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 associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param parameters: Resource create parameters. Is either a PrivateEndpointConnection type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, 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.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", self._config.api_version)) + 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) + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, 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 associated + with the Azure resource. 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", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + 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, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_link_resources_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..30b80c41350d --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_private_link_resources_operations.py @@ -0,0 +1,252 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateLinkResources", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/privateLinkResources/{groupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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 + ) -> _models.PrivateLinkResourceListResult: + """Lists the private link resources for MySQL 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: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("PrivateLinkResourceListResult", 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, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource for MySQL 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 or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py new file mode 100644 index 000000000000..fd6db8796676 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_replicas_operations.py @@ -0,0 +1,178 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/replicas", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Server"]: + """List all the replicas 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 + :return: An iterator like instance of either Server or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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_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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py new file mode 100644 index 000000000000..8b9b817bfc0e --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_migration_operations.py @@ -0,0 +1,216 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (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 MySQLManagementClientConfiguration +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_cutover_migration_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-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/cutoverMigration", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_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 _cutover_migration_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", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_cutover_migration_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_cutover_migration( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> LROPoller[_models.Server]: + """Cutover migration for MySQL import, it will switch source elastic server DNS to flexible + 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 either Server or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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._cutover_migration_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("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, 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.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 + ) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py new file mode 100644 index 000000000000..4f70018fc553 --- /dev/null +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/azure/mgmt/mysqlflexibleservers/operations/_servers_operations.py @@ -0,0 +1,2327 @@ +# 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 +import urllib.parse + +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 MySQLManagementClientConfiguration +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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/flexibleServers") + 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", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/detachVNet", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/failover", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/resetGtid", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/restart", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/start", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/stop", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-06-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.DBforMySQL/flexibleServers/{serverName}/validateEstimateHighAvailability", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serverName": _SERIALIZER.url( + "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9][-a-z0-9]*(? None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MySQLManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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.Server"]: + """List all the servers in a given subscription. + + :return: An iterator like instance of either Server or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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, **kwargs: Any) -> ItemPaged["_models.Server"]: + """List all the servers in a given 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 either Server or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _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, **kwargs: Any) -> _models.Server: + """Gets information about 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: Server or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.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", self._config.api_version)) + 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, + 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_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", self._config.api_version)) + 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_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 == 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.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( + self, + resource_group_name: str, + server_name: str, + parameters: _models.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.models.Server] + :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[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates a new server or updates an existing server. The update action will overwrite the + existing 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 required parameters for creating or updating a server. Is either a + Server type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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): + 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, 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.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.ServerForUpdate, 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", self._config.api_version)) + 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, "ServerForUpdate") + + _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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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.ServerForUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate + :keyword content_type: Body Parameter 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.mysqlflexibleservers.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 an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates an existing server. The request body can contain one to many of the properties present + in the normal server definition. + + :param resource_group_name: The name of the resource group. The 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 required parameters for updating a server. Is either a ServerForUpdate + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerForUpdate 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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.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, 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.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", self._config.api_version)) + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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. 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + 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, 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[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 _detach_v_net_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, 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", self._config.api_version)) + 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, "ServerDetachVNetParameter") + + _request = build_detach_v_net_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerDetachVNetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter + :keyword content_type: Body Parameter 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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Required. + :type parameters: IO[bytes] + :keyword content_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.mysqlflexibleservers.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_detach_v_net( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerDetachVNetParameter, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Detach VNet 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 + :param parameters: The required parameters for detach vnet on a server. Is either a + ServerDetachVNetParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerDetachVNetParameter 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.mysqlflexibleservers.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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._detach_v_net_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, 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.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 _failover_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", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_failover(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Manual failover 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._failover_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, 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 _reset_gtid_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, 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", self._config.api_version)) + 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, "ServerGtidSetParameter") + + _request = build_reset_gtid_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerGtidSetParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter + :keyword content_type: Body Parameter 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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Required. + :type parameters: IO[bytes] + :keyword content_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_reset_gtid( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerGtidSetParameter, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Resets GTID 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 + :param parameters: The required parameters for resetting GTID on a server. Is either a + ServerGtidSetParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerGtidSetParameter 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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reset_gtid_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, 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[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 _restart_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, 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", self._config.api_version)) + 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, "ServerRestartParameter") + + _request = build_restart_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerRestartParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter + :keyword content_type: Body Parameter 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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts 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 required parameters for restarting a server. Required. + :type parameters: IO[bytes] + :keyword content_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_restart( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerRestartParameter, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Restarts 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 required parameters for restarting a server. Is either a + ServerRestartParameter type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.ServerRestartParameter 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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._restart_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, 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 _start_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", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Starts 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_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, 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 _stop_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", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_stop_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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + 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_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Stops 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 either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._stop_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, 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 + + @overload + def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: _models.HighAvailabilityValidationEstimation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: HighAvailabilityValidationEstimation or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_estimate_high_availability( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.HighAvailabilityValidationEstimation, IO[bytes]], + **kwargs: Any + ) -> _models.HighAvailabilityValidationEstimation: + """Validate a deployment of high availability. + + :param resource_group_name: The name of the resource group. The 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 required parameters for validation of high availability deployment. Is + either a HighAvailabilityValidationEstimation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + or IO[bytes] + :return: HighAvailabilityValidationEstimation or the result of cls(response) + :rtype: ~azure.mgmt.mysqlflexibleservers.models.HighAvailabilityValidationEstimation + :raises ~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", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.HighAvailabilityValidationEstimation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "HighAvailabilityValidationEstimation") + + _request = build_validate_estimate_high_availability_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) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("HighAvailabilityValidationEstimation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py index 1d9bd29021b3..1b950252e2d6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.advanced_threat_protection_settings.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AdvancedThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_list.py index 132bad404c39..fff44ec7b64f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_list.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.advanced_threat_protection_settings.list( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsList.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AdvancedThreatProtectionSettingsList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py index 6f7da739ddee..feeb27b8c674 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_disabled.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.advanced_threat_protection_settings.begin_update( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPatchDisabled.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AdvancedThreatProtectionSettingsPatchDisabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py index 23f4ff18e734..4af9d4ed2921 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_patch_enabled.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.advanced_threat_protection_settings.begin_update( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPatchEnabled.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AdvancedThreatProtectionSettingsPatchEnabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py index 50fc66f6f76d..378c807121c0 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_disabled.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.advanced_threat_protection_settings.begin_update_put( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPutDisabled.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AdvancedThreatProtectionSettingsPutDisabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py index 2ec6388d83bc..98a83052a43c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/advanced_threat_protection_settings_put_enabled.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.advanced_threat_protection_settings.begin_update_put( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/AdvancedThreatProtectionSettingsPutEnabled.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AdvancedThreatProtectionSettingsPutEnabled.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_create.py index 3195009dc94e..0c93d9507101 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.azure_ad_administrators.begin_create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorCreate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AzureADAdministratorCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_delete.py index 07c1ae1c1086..722e96608772 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_delete.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.azure_ad_administrators.begin_delete( @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorDelete.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AzureADAdministratorDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_get.py index 5f4b3096bd88..8bfeb216798a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrator_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.azure_ad_administrators.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AzureADAdministratorGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_list_by_server.py index ba91d8b176c1..aee3e9766d5d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/azure_ad_administrators_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.azure_ad_administrators.list_by_server( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/AzureADAdministratorsListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/AzureADAdministratorsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_export.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_export.py index 8bce0a56045c..9b87d09ad958 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_export.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_and_export.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.backup_and_export.begin_create( @@ -41,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/BackupAndExport.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/BackupAndExport.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_get.py index 0ee990f18523..324f40da48aa 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.backups.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/BackupGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/BackupGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_put.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_put.py index faf010f96a09..5447c0c3c329 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_put.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backup_put.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.backups.put( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/BackupPut.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/BackupPut.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_list_by_server.py index a944b8df2458..bbd00c78bcb3 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/backups_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.backups.list_by_server( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/BackupsListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/BackupsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_list.py index 08cea91cb823..763a1613f9ef 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capabilities_by_location_list.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.location_based_capabilities.list( @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/CapabilitiesByLocationList.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/CapabilitiesByLocationList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_by_location.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_by_location.py index d7f8ef6f6fd5..05b42f5a29bb 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_by_location.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_by_location.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,16 +28,15 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.location_based_capability_set.get( location_name="WestUS", - capability_set_name="default", ) print(response) -# x-ms-original-file: 2025-06-01-preview/CapabilitySetByLocation.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/CapabilitySetByLocation.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_list_by_location.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_list_by_location.py index 5266e933cb6f..b6aae10da44d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_list_by_location.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/capability_set_list_by_location.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.location_based_capability_set.list( @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/CapabilitySetListByLocation.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/CapabilitySetListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py index 8237ffa57960..19c9287f009e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.check_name_availability.execute( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/CheckNameAvailability.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_location.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_location.py index 583aa94afb7f..8108aaa7ddfe 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_location.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_name_availability_without_location.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.check_name_availability_without_location.execute( @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/CheckNameAvailabilityWithoutLocation.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/CheckNameAvailabilityWithoutLocation.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.py index 5bfc05420044..7552bf984c59 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/check_virtual_network_subnet_usage.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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.check_virtual_network_subnet_usage.execute( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/CheckVirtualNetworkSubnetUsage.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/CheckVirtualNetworkSubnetUsage.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_create_or_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_create_or_update.py index 805834b5fc50..8837695d5180 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_create_or_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_create_or_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.configurations.begin_create_or_update( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ConfigurationCreateOrUpdate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ConfigurationCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_get.py index 7e00bfd4a722..ad2124b62a3a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.configurations.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ConfigurationGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ConfigurationGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_update.py index 5a2353c6d53b..dc1bce5f0410 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configuration_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.configurations.begin_update( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ConfigurationUpdate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ConfigurationUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_update.py index dfce75834fd5..4b9e0bf9fe17 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_batch_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.configurations.begin_batch_update( @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ConfigurationsBatchUpdate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ConfigurationsBatchUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_list_by_server.py index a43f7bc5cbd3..d535b3906c2a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/configurations_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.configurations.list_by_server( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/ConfigurationsListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ConfigurationsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py index b9933751fa5c..e8077d4edf4c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/cutover_migration.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers_migration.begin_cutover_migration( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/CutoverMigration.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/CutoverMigration.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_create.py index 1111ead8869a..eb885481d1da 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_create.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.databases.begin_create_or_update( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/DatabaseCreate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/DatabaseCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_delete.py index 2f7edda1cdfd..4d9e7724c1bc 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_delete.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.databases.begin_delete( @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/DatabaseDelete.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/DatabaseDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_get.py index ce5771db35bf..990c0bfdd26a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/database_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.databases.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/DatabaseGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/DatabaseGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_list_by_server.py index 0b2b53fe1f64..034e76f8821a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/databases_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.databases.list_by_server( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/DatabasesListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/DatabasesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_create.py index be7bad88281c..f2ff2b4766e7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_create.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.firewall_rules.begin_create_or_update( @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/FirewallRuleCreate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/FirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_delete.py index c2614aed4dab..d95096788349 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_delete.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.firewall_rules.begin_delete( @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/FirewallRuleDelete.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/FirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_get.py index 5dd066a62324..818d3975525f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rule_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.firewall_rules.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/FirewallRuleGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/FirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_list_by_server.py index 2b996ab77b78..f9395c93bde3 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/firewall_rules_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.firewall_rules.list_by_server( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/FirewallRulesListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/FirewallRulesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py index c26b8878ac62..9444c3be40fb 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/get_private_dns_zone_suffix.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -34,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/GetPrivateDnsZoneSuffix.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/GetPrivateDnsZoneSuffix.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_list_by_server.py index d93db436e54a..8a88b228731e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/log_files_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.log_files.list_by_server( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/LogFilesListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/LogFilesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup.py index 86dd799dca33..7c9802ad6688 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.long_running_backup.begin_create( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/LongRunningBackup.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/LongRunningBackup.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.py index 8b4ffc231e8d..d96289475820 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_delete.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.long_running_backup.begin_delete( @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/LongRunningBackupDelete.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/LongRunningBackupDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_get.py index d86b074713d7..8eaba1a09a07 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backup_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.long_running_backups.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/LongRunningBackupGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/LongRunningBackupGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_list_by_server.py index e436eb8f48f5..40644e6bbbf6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/long_running_backups_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.long_running_backups.list( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/LongRunningBackupsListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/LongRunningBackupsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py index bf0f090e454b..ad9d0e8cd12d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_in_virtual_canary.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_update( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/MaintenancePolicyPatchOptInVirtualCanary.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/MaintenancePolicyPatchOptInVirtualCanary.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py index 938a96e17713..6ee9a754eb0e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_policy_patch_opt_out_virtual_canary.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_update( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/MaintenancePolicyPatchOptOutVirtualCanary.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/MaintenancePolicyPatchOptOutVirtualCanary.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py index 1d64ab8cc4f0..f8a5234b14ab 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_read.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.maintenances.read( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/MaintenanceRead.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/MaintenanceRead.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_update.py index 685a7287dfc7..8e50a41b2e53 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenance_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.maintenances.begin_update( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/MaintenanceUpdate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/MaintenanceUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_list_by_server.py index 1b774360d783..a338ae267a4d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/maintenances_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.maintenances.list( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/MaintenancesListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/MaintenancesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_export.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_export.py index 0c29d1674198..bc00cbaee41a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_export.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_backup_and_export.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.operation_progress.get( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/OperationProgress_Get_BackupAndExport.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/OperationProgress_Get_BackupAndExport.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py index 6fb637b5a988..ff52c84ffeee 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_progress_get_import_from_storage.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.operation_progress.get( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/OperationProgress_Get_ImportFromStorage.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/OperationProgress_Get_ImportFromStorage.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_get.py index d442089123d2..a143279aad66 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operation_results_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.operation_results.get( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/OperationResults_Get.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/OperationResults_Get.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_list.py index 7873a0c29667..50561f47d69e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/operations_list.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/OperationsList.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_delete.py index b2f946a764dc..fafe804ac1c5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_delete.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) client.private_endpoint_connections.begin_delete( @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionDelete.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/PrivateEndpointConnectionDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_get.py index b66e2eb7fa2f..b3a68ed578c4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.private_endpoint_connections.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/PrivateEndpointConnectionGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_list.py index 886f7f9632d2..6446cf0dbbb8 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_list.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.private_endpoint_connections.list_by_server( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionList.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/PrivateEndpointConnectionList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_update.py index 46ddfb75760e..4483828f0d3e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_endpoint_connection_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.private_endpoint_connections.begin_create_or_update( @@ -37,7 +38,7 @@ def main(): parameters={ "properties": { "privateLinkServiceConnectionState": { - "description": "Approved by `johndoe@contoso.com `_", + "description": "Approved by johndoe@contoso.com", "status": "Approved", } } @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/PrivateEndpointConnectionUpdate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/PrivateEndpointConnectionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_get.py index 335c2541b2f0..7d34cb491fb6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.private_link_resources.get( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/PrivateLinkResourcesGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/PrivateLinkResourcesGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_list.py index 02cda7c8a770..82d887b7f2c9 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/private_link_resources_list.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +28,16 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.private_link_resources.list_by_server( resource_group_name="Default", server_name="test-svr", ) - for item in response: - print(item) + print(response) -# x-ms-original-file: 2025-06-01-preview/PrivateLinkResourcesList.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/PrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_list_by_server.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_list_by_server.py index 13adf769a267..122f8a5ba44b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_list_by_server.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/replicas_list_by_server.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.replicas.list_by_server( @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/ReplicasListByServer.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ReplicasListByServer.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create.py index acbab5d6995d..c21b18c29c69 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_create( @@ -57,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerCreate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerCreate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_replica.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_replica.py index 992dd1066cc4..ab40f897c19a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_replica.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_create( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerCreateReplica.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerCreateReplica.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.py index d9a76b7bbba5..1a4e8a08c8c7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_byok.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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_create( @@ -71,6 +71,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerCreateWithBYOK.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerCreateWithBYOK.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py index effed8aaf406..c6958c6e7699 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_database_port.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_create( @@ -58,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerCreateWithDatabasePort.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerCreateWithDatabasePort.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.py index 890b97b583bf..3ab00ceaea7c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_lower_case_table_names.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_create( @@ -63,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerCreateWithLowerCaseTableNames.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerCreateWithLowerCaseTableNames.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_point_in_time_restore.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_point_in_time_restore.py index ff3ab7e93660..8129ed153378 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_point_in_time_restore.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_create_with_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_create( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerCreateWithPointInTimeRestore.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerCreateWithPointInTimeRestore.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_delete.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_delete.py index 403a075a8d11..678d8635fadd 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_delete.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_delete.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.servers.begin_delete( @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/ServerDelete.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerDelete.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py index 7def78ea2ef0..519ed741d734 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_detach_vnet.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_detach_v_net( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerDetachVNet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerDetachVNet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_failover.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_failover.py index 0db72c5bc4e4..7d20d8c2613b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_failover.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_failover.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.servers.begin_failover( @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/ServerFailover.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerFailover.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get.py index bb95445207ea..ba8f85e03bf1 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.get( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerGet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerGet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py index 262896a308da..0b38af72427c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_get_with_vnet.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.get( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerGetWithVnet.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerGetWithVnet.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py index 4a0212c54946..55cb60346fbf 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_reset_gtid.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.servers.begin_reset_gtid( @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/ServerResetGtid.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerResetGtid.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py index 4780ceb74b86..182468095d0c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_restart.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.servers.begin_restart( @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/ServerRestart.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerRestart.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py index 27fcd576006e..03a520f4ac3d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_start.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.servers.begin_start( @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/ServerStart.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerStart.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py index e637f8ae48e7..d32720e167ee 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_stop.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) client.servers.begin_stop( @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01-preview/ServerStop.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerStop.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update.py index 0f61f5b905e4..1f8555bdd164 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_update( @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerUpdate.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerUpdate.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.py index 0610a61d0ca7..ef544d225666 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_byok.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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_update( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerUpdateWithBYOK.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerUpdateWithBYOK.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py index 15f2497d071b..724269720550 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_update_with_customer_maintenance_window.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.begin_update( @@ -48,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerUpdateWithCustomerMaintenanceWindow.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerUpdateWithCustomerMaintenanceWindow.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py index f9445644acef..702e6877dee0 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/server_validate_estimate_high_availability.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.validate_estimate_high_availability( @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ServerValidateEstimateHighAvailability.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServerValidateEstimateHighAvailability.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list.py index e18d70be226b..aa2cc68c6059 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.list() @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/ServersList.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServersList.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list_by_resource_group.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list_by_resource_group.py index 2d50043ced8c..76ebdb2152c7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list_by_resource_group.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/servers_list_by_resource_group.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.servers.list_by_resource_group( @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01-preview/ServersListByResourceGroup.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ServersListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_backup.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_backup.py index 8360337e06df..9ec5f7f01e0e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_backup.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_samples/validate_backup.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft 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. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = MySQLManagementClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", ) response = client.backup_and_export.validate_backup( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01-preview/ValidateBackup.json +# x-ms-original-file: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2025-06-01-preview/examples/ValidateBackup.json if __name__ == "__main__": main() diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/conftest.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/conftest.py index 84ee2c1dc115..1ba62909429d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/conftest.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations.py index 88eef5b97021..64b9795c2a9d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestMySQLManagementAdvancedThreatProtectionSettingsOperations(AzureMgmtRec def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_advanced_threat_protection_settings_list(self, resource_group): + response = self.client.advanced_threat_protection_settings.list( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-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_advanced_threat_protection_settings_get(self, resource_group): @@ -25,6 +37,7 @@ def test_advanced_threat_protection_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -38,9 +51,11 @@ def test_advanced_threat_protection_settings_begin_update_put(self, resource_gro server_name="str", advanced_threat_protection_name="str", parameters={ + "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "properties": {"creationTime": "2020-02-20 00:00:00", "provisioningState": "str", "state": "str"}, + "provisioningState": "str", + "state": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -51,6 +66,7 @@ def test_advanced_threat_protection_settings_begin_update_put(self, resource_gro }, "type": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -63,19 +79,9 @@ def test_advanced_threat_protection_settings_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - parameters={"properties": {"state": "str"}}, + parameters={"state": "str"}, + api_version="2025-06-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_advanced_threat_protection_settings_list(self, resource_group): - response = self.client.advanced_threat_protection_settings.list( - 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations_async.py index 89027672c837..f0578408432d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_advanced_threat_protection_settings_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestMySQLManagementAdvancedThreatProtectionSettingsOperationsAsync(AzureMg def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_advanced_threat_protection_settings_list(self, resource_group): + response = self.client.advanced_threat_protection_settings.list( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-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_advanced_threat_protection_settings_get(self, resource_group): @@ -26,6 +38,7 @@ async def test_advanced_threat_protection_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -40,9 +53,11 @@ async def test_advanced_threat_protection_settings_begin_update_put(self, resour server_name="str", advanced_threat_protection_name="str", parameters={ + "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "properties": {"creationTime": "2020-02-20 00:00:00", "provisioningState": "str", "state": "str"}, + "provisioningState": "str", + "state": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -53,6 +68,7 @@ async def test_advanced_threat_protection_settings_begin_update_put(self, resour }, "type": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -67,20 +83,10 @@ async def test_advanced_threat_protection_settings_begin_update(self, resource_g resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - parameters={"properties": {"state": "str"}}, + parameters={"state": "str"}, + api_version="2025-06-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_advanced_threat_protection_settings_list(self, resource_group): - response = self.client.advanced_threat_protection_settings.list( - 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations.py index a72be9b0cde9..e2619edb12f6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestMySQLManagementAzureADAdministratorsOperations(AzureMgmtRecordedTestCa def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_ad_administrators_list_by_server(self, resource_group): + response = self.client.azure_ad_administrators.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-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_azure_ad_administrators_get(self, resource_group): @@ -25,6 +37,7 @@ def test_azure_ad_administrators_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -38,15 +51,12 @@ def test_azure_ad_administrators_begin_create_or_update(self, resource_group): server_name="str", administrator_name="str", parameters={ + "administratorType": "str", "id": "str", + "identityResourceId": "str", + "login": "str", "name": "str", - "properties": { - "administratorType": "str", - "identityResourceId": "str", - "login": "str", - "sid": "str", - "tenantId": "str", - }, + "sid": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -55,8 +65,10 @@ def test_azure_ad_administrators_begin_create_or_update(self, resource_group): "lastModifiedBy": "str", "lastModifiedByType": "str", }, + "tenantId": "str", "type": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -69,18 +81,8 @@ def test_azure_ad_administrators_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", + api_version="2025-06-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_azure_ad_administrators_list_by_server(self, resource_group): - response = self.client.azure_ad_administrators.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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations_async.py index e8435bfd2aea..d3497944f82c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_azure_ad_administrators_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestMySQLManagementAzureADAdministratorsOperationsAsync(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_ad_administrators_list_by_server(self, resource_group): + response = self.client.azure_ad_administrators.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-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_azure_ad_administrators_get(self, resource_group): @@ -26,6 +38,7 @@ async def test_azure_ad_administrators_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -40,15 +53,12 @@ async def test_azure_ad_administrators_begin_create_or_update(self, resource_gro server_name="str", administrator_name="str", parameters={ + "administratorType": "str", "id": "str", + "identityResourceId": "str", + "login": "str", "name": "str", - "properties": { - "administratorType": "str", - "identityResourceId": "str", - "login": "str", - "sid": "str", - "tenantId": "str", - }, + "sid": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -57,8 +67,10 @@ async def test_azure_ad_administrators_begin_create_or_update(self, resource_gro "lastModifiedBy": "str", "lastModifiedByType": "str", }, + "tenantId": "str", "type": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -73,19 +85,9 @@ async def test_azure_ad_administrators_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", + api_version="2025-06-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_azure_ad_administrators_list_by_server(self, resource_group): - response = self.client.azure_ad_administrators.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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations.py index e793c89f845e..54c93a570039 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,6 +28,7 @@ def test_backup_and_export_begin_create(self, resource_group): "backupSettings": {"backupName": "str", "backupFormat": "str"}, "targetDetails": "backup_store_details", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -39,6 +40,7 @@ def test_backup_and_export_validate_backup(self, resource_group): response = self.client.backup_and_export.validate_backup( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations_async.py index 1ab985e2ba50..abb8f6b6940e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backup_and_export_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -30,6 +30,7 @@ async def test_backup_and_export_begin_create(self, resource_group): "backupSettings": {"backupName": "str", "backupFormat": "str"}, "targetDetails": "backup_store_details", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -42,6 +43,7 @@ async def test_backup_and_export_validate_backup(self, resource_group): response = await self.client.backup_and_export.validate_backup( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations.py index efae36c30df4..be67ac07dd1c 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,23 +20,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_backups_get(self, resource_group): - response = self.client.backups.get( + def test_backups_list_by_server(self, resource_group): + response = self.client.backups.list_by_server( resource_group_name=resource_group.name, server_name="str", - backup_name="str", + api_version="2025-06-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_backups_put(self, resource_group): - response = self.client.backups.put( + def test_backups_get(self, resource_group): + response = self.client.backups.get( resource_group_name=resource_group.name, server_name="str", backup_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -44,11 +45,13 @@ def test_backups_put(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_backups_list_by_server(self, resource_group): - response = self.client.backups.list_by_server( + def test_backups_put(self, resource_group): + response = self.client.backups.put( resource_group_name=resource_group.name, server_name="str", + backup_name="str", + api_version="2025-06-01-preview", ) - result = [r for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations_async.py index d5bce47fa14a..ff3927e81d7b 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_backups_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,23 +21,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_backups_get(self, resource_group): - response = await self.client.backups.get( + async def test_backups_list_by_server(self, resource_group): + response = self.client.backups.list_by_server( resource_group_name=resource_group.name, server_name="str", - backup_name="str", + api_version="2025-06-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_backups_put(self, resource_group): - response = await self.client.backups.put( + async def test_backups_get(self, resource_group): + response = await self.client.backups.get( resource_group_name=resource_group.name, server_name="str", backup_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -45,11 +46,13 @@ async def test_backups_put(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_backups_list_by_server(self, resource_group): - response = self.client.backups.list_by_server( + async def test_backups_put(self, resource_group): + response = await self.client.backups.put( resource_group_name=resource_group.name, server_name="str", + backup_name="str", + api_version="2025-06-01-preview", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations.py index 5a4b2186dbed..12b74e65e477 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def test_check_name_availability_execute(self, resource_group): response = self.client.check_name_availability.execute( location_name="str", name_availability_request={"name": "str", "type": "str"}, + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations_async.py index 58fe32117213..3d1f5f4694b7 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,6 +25,7 @@ async def test_check_name_availability_execute(self, resource_group): response = await self.client.check_name_availability.execute( location_name="str", name_availability_request={"name": "str", "type": "str"}, + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations.py index d46d6ed395e5..729737342d4a 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -23,6 +23,7 @@ def setup_method(self, method): def test_check_name_availability_without_location_execute(self, resource_group): response = self.client.check_name_availability_without_location.execute( name_availability_request={"name": "str", "type": "str"}, + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations_async.py index f2e18a477ead..44590e8c6c48 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_name_availability_without_location_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def setup_method(self, method): async def test_check_name_availability_without_location_execute(self, resource_group): response = await self.client.check_name_availability_without_location.execute( name_availability_request={"name": "str", "type": "str"}, + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations.py index edcb6c0b4844..971542e5168e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def test_check_virtual_network_subnet_usage_execute(self, resource_group): response = self.client.check_virtual_network_subnet_usage.execute( location_name="str", parameters={"virtualNetworkResourceId": "str"}, + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations_async.py index 517ed2192b59..879cc1f08327 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_check_virtual_network_subnet_usage_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,6 +25,7 @@ async def test_check_virtual_network_subnet_usage_execute(self, resource_group): response = await self.client.check_virtual_network_subnet_usage.execute( location_name="str", parameters={"virtualNetworkResourceId": "str"}, + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations.py index 9db3879d456f..f0aeb92720f2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestMySQLManagementConfigurationsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_configurations_list_by_server(self, resource_group): + response = self.client.configurations.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-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_configurations_get(self, resource_group): @@ -25,6 +37,7 @@ def test_configurations_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", configuration_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -38,21 +51,18 @@ def test_configurations_begin_create_or_update(self, resource_group): server_name="str", configuration_name="str", parameters={ + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", "id": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", "name": "str", - "properties": { - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", - "source": "str", - "value": "str", - }, + "source": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -62,7 +72,9 @@ def test_configurations_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", + "value": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -76,21 +88,18 @@ def test_configurations_begin_update(self, resource_group): server_name="str", configuration_name="str", parameters={ + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", "id": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", "name": "str", - "properties": { - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", - "source": "str", - "value": "str", - }, + "source": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -100,33 +109,22 @@ def test_configurations_begin_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", + "value": "str", }, + api_version="2025-06-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_configurations_list_by_server(self, resource_group): - response = self.client.configurations.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_configurations_begin_batch_update(self, resource_group): response = self.client.configurations.begin_batch_update( resource_group_name=resource_group.name, server_name="str", - parameters={ - "resetAllToDefault": "str", - "value": [{"name": "str", "properties": {"source": "str", "value": "str"}}], - }, + parameters={"resetAllToDefault": "str", "value": [{"name": "str", "source": "str", "value": "str"}]}, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations_async.py index 9bfc9d68a778..1fe002ce591f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_configurations_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestMySQLManagementConfigurationsOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_configurations_list_by_server(self, resource_group): + response = self.client.configurations.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-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_configurations_get(self, resource_group): @@ -26,6 +38,7 @@ async def test_configurations_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", configuration_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -40,21 +53,18 @@ async def test_configurations_begin_create_or_update(self, resource_group): server_name="str", configuration_name="str", parameters={ + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", "id": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", "name": "str", - "properties": { - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", - "source": "str", - "value": "str", - }, + "source": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -64,7 +74,9 @@ async def test_configurations_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", + "value": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -80,21 +92,18 @@ async def test_configurations_begin_update(self, resource_group): server_name="str", configuration_name="str", parameters={ + "allowedValues": "str", + "currentValue": "str", + "dataType": "str", + "defaultValue": "str", + "description": "str", + "documentationLink": "str", "id": "str", + "isConfigPendingRestart": "str", + "isDynamicConfig": "str", + "isReadOnly": "str", "name": "str", - "properties": { - "allowedValues": "str", - "currentValue": "str", - "dataType": "str", - "defaultValue": "str", - "description": "str", - "documentationLink": "str", - "isConfigPendingRestart": "str", - "isDynamicConfig": "str", - "isReadOnly": "str", - "source": "str", - "value": "str", - }, + "source": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -104,24 +113,15 @@ async def test_configurations_begin_update(self, resource_group): "lastModifiedByType": "str", }, "type": "str", + "value": "str", }, + api_version="2025-06-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_configurations_list_by_server(self, resource_group): - response = self.client.configurations.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_configurations_begin_batch_update(self, resource_group): @@ -129,10 +129,8 @@ async def test_configurations_begin_batch_update(self, resource_group): await self.client.configurations.begin_batch_update( resource_group_name=resource_group.name, server_name="str", - parameters={ - "resetAllToDefault": "str", - "value": [{"name": "str", "properties": {"source": "str", "value": "str"}}], - }, + parameters={"resetAllToDefault": "str", "value": [{"name": "str", "source": "str", "value": "str"}]}, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations.py index 8579f0368e85..588169363a6e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestMySQLManagementDatabasesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) + @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="2025-06-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): @@ -25,6 +37,7 @@ def test_databases_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -38,9 +51,10 @@ def test_databases_begin_create_or_update(self, resource_group): server_name="str", database_name="str", parameters={ + "charset": "str", + "collation": "str", "id": "str", "name": "str", - "properties": {"charset": "str", "collation": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -51,6 +65,7 @@ def test_databases_begin_create_or_update(self, resource_group): }, "type": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -63,18 +78,8 @@ def test_databases_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", + api_version="2025-06-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_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 - # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations_async.py index e65a91e12a54..4179fd2633ac 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_databases_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestMySQLManagementDatabasesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @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="2025-06-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): @@ -26,6 +38,7 @@ async def test_databases_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -40,9 +53,10 @@ async def test_databases_begin_create_or_update(self, resource_group): server_name="str", database_name="str", parameters={ + "charset": "str", + "collation": "str", "id": "str", "name": "str", - "properties": {"charset": "str", "collation": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -53,6 +67,7 @@ async def test_databases_begin_create_or_update(self, resource_group): }, "type": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -67,19 +82,9 @@ async def test_databases_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", + api_version="2025-06-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_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 - # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations.py index 260d5b11c7ed..4042c12b13a5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestMySQLManagementFirewallRulesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + 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="2025-06-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_firewall_rules_get(self, resource_group): @@ -25,6 +37,7 @@ def test_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -38,7 +51,8 @@ def test_firewall_rules_begin_create_or_update(self, resource_group): server_name="str", firewall_rule_name="str", parameters={ - "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "endIpAddress": "str", + "startIpAddress": "str", "id": "str", "name": "str", "systemData": { @@ -51,6 +65,7 @@ def test_firewall_rules_begin_create_or_update(self, resource_group): }, "type": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -63,18 +78,8 @@ def test_firewall_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", + api_version="2025-06-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_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", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations_async.py index 8526e1cadb1c..84b2798ca4e9 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_firewall_rules_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestMySQLManagementFirewallRulesOperationsAsync(AzureMgmtRecordedTestCase) def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + 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="2025-06-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_firewall_rules_get(self, resource_group): @@ -26,6 +38,7 @@ async def test_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -40,7 +53,8 @@ async def test_firewall_rules_begin_create_or_update(self, resource_group): server_name="str", firewall_rule_name="str", parameters={ - "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "endIpAddress": "str", + "startIpAddress": "str", "id": "str", "name": "str", "systemData": { @@ -53,6 +67,7 @@ async def test_firewall_rules_begin_create_or_update(self, resource_group): }, "type": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -67,19 +82,9 @@ async def test_firewall_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", + api_version="2025-06-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_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", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations.py index 22b5185e2652..8407e36cd1f2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,7 +21,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_get_private_dns_zone_suffix_execute(self, resource_group): - response = self.client.get_private_dns_zone_suffix.execute() + response = self.client.get_private_dns_zone_suffix.execute( + api_version="2025-06-01-preview", + ) # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations_async.py index 163587a60fcf..1e7d0acfae44 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_get_private_dns_zone_suffix_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -22,7 +22,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_get_private_dns_zone_suffix_execute(self, resource_group): - response = await self.client.get_private_dns_zone_suffix.execute() + response = await self.client.get_private_dns_zone_suffix.execute( + api_version="2025-06-01-preview", + ) # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations.py index 268374d3acbf..883146735220 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -23,6 +23,7 @@ def setup_method(self, method): def test_location_based_capabilities_list(self, resource_group): response = self.client.location_based_capabilities.list( location_name="str", + api_version="2025-06-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations_async.py index f970296254d8..fb17b249cfd6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capabilities_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def setup_method(self, method): async def test_location_based_capabilities_list(self, resource_group): response = self.client.location_based_capabilities.list( location_name="str", + api_version="2025-06-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations.py index aca80d00b6bf..be3fdfa75cf8 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,21 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_location_based_capability_set_get(self, resource_group): - response = self.client.location_based_capability_set.get( + def test_location_based_capability_set_list(self, resource_group): + response = self.client.location_based_capability_set.list( location_name="str", - capability_set_name="str", + api_version="2025-06-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_location_based_capability_set_list(self, resource_group): - response = self.client.location_based_capability_set.list( + def test_location_based_capability_set_get(self, resource_group): + response = self.client.location_based_capability_set.get( location_name="str", + capability_set_name="default", + api_version="2025-06-01-preview", ) - result = [r for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations_async.py index 2a8e756f932a..d8360d65b7e2 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_location_based_capability_set_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,21 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_location_based_capability_set_get(self, resource_group): - response = await self.client.location_based_capability_set.get( + async def test_location_based_capability_set_list(self, resource_group): + response = self.client.location_based_capability_set.list( location_name="str", - capability_set_name="str", + api_version="2025-06-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_location_based_capability_set_list(self, resource_group): - response = self.client.location_based_capability_set.list( + async def test_location_based_capability_set_get(self, resource_group): + response = await self.client.location_based_capability_set.get( location_name="str", + capability_set_name="default", + api_version="2025-06-01-preview", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations.py index 05f553414101..67d89a630c62 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def test_log_files_list_by_server(self, resource_group): response = self.client.log_files.list_by_server( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations_async.py index 1d567d247718..dc725dd66b40 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_log_files_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,6 +25,7 @@ async def test_log_files_list_by_server(self, resource_group): response = self.client.log_files.list_by_server( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations.py index 5beec4ca0ab2..0c20fe8d151e 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,6 +25,7 @@ def test_long_running_backup_begin_create(self, resource_group): resource_group_name=resource_group.name, server_name="str", backup_name="str", + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -37,6 +38,7 @@ def test_long_running_backup_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", backup_name="str", + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations_async.py index 120fb854853b..f9a158d647e1 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backup_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,6 +27,7 @@ async def test_long_running_backup_begin_create(self, resource_group): resource_group_name=resource_group.name, server_name="str", backup_name="str", + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -41,6 +42,7 @@ async def test_long_running_backup_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", backup_name="str", + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations.py index 5d907902984f..c5f7e7a01796 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,23 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_running_backups_get(self, resource_group): - response = self.client.long_running_backups.get( + def test_long_running_backups_list(self, resource_group): + response = self.client.long_running_backups.list( resource_group_name=resource_group.name, server_name="str", - backup_name="str", + api_version="2025-06-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_running_backups_list(self, resource_group): - response = self.client.long_running_backups.list( + def test_long_running_backups_get(self, resource_group): + response = self.client.long_running_backups.get( resource_group_name=resource_group.name, server_name="str", + backup_name="str", + api_version="2025-06-01-preview", ) - result = [r for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations_async.py index f1a1a89ebf0e..1425cb3dbe93 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_backups_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_long_running_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,23 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_running_backups_get(self, resource_group): - response = await self.client.long_running_backups.get( + async def test_long_running_backups_list(self, resource_group): + response = self.client.long_running_backups.list( resource_group_name=resource_group.name, server_name="str", - backup_name="str", + api_version="2025-06-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_running_backups_list(self, resource_group): - response = self.client.long_running_backups.list( + async def test_long_running_backups_get(self, resource_group): + response = await self.client.long_running_backups.get( resource_group_name=resource_group.name, server_name="str", + backup_name="str", + api_version="2025-06-01-preview", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations.py index 625b58d590cc..1023562c1a35 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,35 +20,38 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_maintenances_read(self, resource_group): - response = self.client.maintenances.read( + def test_maintenances_list(self, resource_group): + response = self.client.maintenances.list( resource_group_name=resource_group.name, server_name="str", - maintenance_name="str", + api_version="2025-06-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_maintenances_begin_update(self, resource_group): - response = self.client.maintenances.begin_update( + def test_maintenances_read(self, resource_group): + response = self.client.maintenances.read( resource_group_name=resource_group.name, server_name="str", maintenance_name="str", - ).result() # call '.result()' to poll until service return final result + api_version="2025-06-01-preview", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_maintenances_list(self, resource_group): - response = self.client.maintenances.list( + def test_maintenances_begin_update(self, resource_group): + response = self.client.maintenances.begin_update( resource_group_name=resource_group.name, server_name="str", - ) - result = [r for r in response] + maintenance_name="str", + api_version="2025-06-01-preview", + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations_async.py index 9493c6c632f6..3ab44bdcd1ca 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_maintenances_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestMySQLManagementMaintenancesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_maintenances_list(self, resource_group): + response = self.client.maintenances.list( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-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_maintenances_read(self, resource_group): @@ -26,6 +38,7 @@ async def test_maintenances_read(self, resource_group): resource_group_name=resource_group.name, server_name="str", maintenance_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -39,19 +52,9 @@ async def test_maintenances_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", maintenance_name="str", + api_version="2025-06-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_maintenances_list(self, resource_group): - response = self.client.maintenances.list( - 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/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations.py index e1f09642b319..a3046841a1d6 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def test_operation_progress_get(self, resource_group): response = self.client.operation_progress.get( location_name="str", operation_id="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations_async.py index 8aee6cac528a..e3c937473a75 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_progress_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,6 +25,7 @@ async def test_operation_progress_get(self, resource_group): response = await self.client.operation_progress.get( location_name="str", operation_id="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations.py index ce04999ebb24..02f2645f22ba 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def test_operation_results_get(self, resource_group): response = self.client.operation_results.get( location_name="str", operation_id="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations_async.py index 6c773713b589..d679042a8042 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operation_results_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,6 +25,7 @@ async def test_operation_results_get(self, resource_group): response = await self.client.operation_results.get( location_name="str", operation_id="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations.py index 911c55d1c42b..f04c2167e84d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,7 +21,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_operations_list(self, resource_group): - response = self.client.operations.list() + response = self.client.operations.list( + api_version="2025-06-01-preview", + ) result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations_async.py index a4a698b7266b..85164b83e9ac 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -22,7 +22,9 @@ 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() + response = self.client.operations.list( + api_version="2025-06-01-preview", + ) result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations.py index 136d676388e4..83153d46ada4 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,18 @@ class TestMySQLManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) + @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="2025-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_private_endpoint_connections_get(self, resource_group): @@ -25,6 +37,7 @@ 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="2025-06-01-preview", ) # please add some check logic here by yourself @@ -38,18 +51,12 @@ 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", - "properties": { - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "groupIds": ["str"], - "privateEndpoint": {"id": "str"}, - "provisioningState": "str", - }, + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -60,6 +67,7 @@ def test_private_endpoint_connections_begin_create_or_update(self, resource_grou }, "type": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -72,18 +80,8 @@ 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="2025-06-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", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations_async.py index 5906dc72fff8..568fa8651740 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_endpoint_connections_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,18 @@ class TestMySQLManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtReco def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list_by_server(self, resource_group): + response = await self.client.private_endpoint_connections.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + api_version="2025-06-01-preview", + ) + + # 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): @@ -26,6 +38,7 @@ 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="2025-06-01-preview", ) # please add some check logic here by yourself @@ -40,18 +53,16 @@ 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", - "properties": { - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "groupIds": ["str"], - "privateEndpoint": {"id": "str"}, - "provisioningState": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", }, + "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -62,6 +73,7 @@ async def test_private_endpoint_connections_begin_create_or_update(self, resourc }, "type": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -76,19 +88,9 @@ 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="2025-06-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 = await self.client.private_endpoint_connections.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations.py index 5cc49761342a..1449ab738916 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,11 @@ def setup_method(self, method): @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="2025-06-01-preview", ) # please add some check logic here by yourself @@ -32,11 +32,13 @@ def test_private_link_resources_get(self, resource_group): @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", + group_name="str", + api_version="2025-06-01-preview", ) - result = [r for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations_async.py index 6128e2b874c0..90cf7f81d7af 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_private_link_resources_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,11 @@ def setup_method(self, method): @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 = await self.client.private_link_resources.list_by_server( resource_group_name=resource_group.name, server_name="str", - group_name="str", + api_version="2025-06-01-preview", ) # please add some check logic here by yourself @@ -33,11 +33,13 @@ async def test_private_link_resources_get(self, resource_group): @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", + group_name="str", + api_version="2025-06-01-preview", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations.py index e59a86991a2c..38b4c3b9c049 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def test_replicas_list_by_server(self, resource_group): response = self.client.replicas.list_by_server( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations_async.py index 3cd89aca3d22..b79208729c40 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_replicas_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,6 +25,7 @@ async def test_replicas_list_by_server(self, resource_group): response = self.client.replicas.list_by_server( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations.py index dfb4e09bef25..72c71b6447de 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,6 +24,7 @@ def test_servers_migration_begin_cutover_migration(self, resource_group): response = self.client.servers_migration.begin_cutover_migration( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations_async.py index b0a829f06af2..6c0685e907d8 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_migration_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,6 +26,7 @@ async def test_servers_migration_begin_cutover_migration(self, resource_group): await self.client.servers_migration.begin_cutover_migration( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations.py index 202a535c690b..f088314f437d 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,12 +18,34 @@ class TestMySQLManagementServersOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_list(self, resource_group): + response = self.client.servers.list( + api_version="2025-06-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="2025-06-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="2025-06-01-preview", ) # please add some check logic here by yourself @@ -37,6 +59,32 @@ def test_servers_begin_create(self, resource_group): server_name="str", parameters={ "location": "str", + "administratorLogin": "str", + "administratorLoginPassword": "str", + "availabilityZone": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "createMode": "str", + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "databasePort": 0, + "fullVersion": "str", + "fullyQualifiedDomainName": "str", + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, "id": "str", "identity": { "principalId": "str", @@ -44,96 +92,65 @@ def test_servers_begin_create(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, + "importSourceProperties": { + "dataDirPath": "str", + "sasToken": "str", + "storageType": "str", + "storageUrl": "str", + }, + "lowerCaseTableNames": 0, + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, "name": "str", - "properties": { - "administratorLogin": "str", - "administratorLoginPassword": "str", - "availabilityZone": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "createMode": "str", - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "databasePort": 0, - "fullVersion": "str", - "fullyQualifiedDomainName": "str", - "highAvailability": { - "mode": "str", - "replicationMode": "str", - "standbyAvailabilityZone": "str", - "state": "str", - }, - "importSourceProperties": { - "dataDirPath": "str", - "sasToken": "str", - "storageType": "str", - "storageUrl": "str", - }, - "lowerCaseTableNames": 0, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", - }, - "privateEndpointConnections": [ - { - "id": "str", - "name": "str", - "properties": { - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "groupIds": ["str"], - "privateEndpoint": {"id": "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", - } - ], - "replicaCapacity": 0, - "replicationRole": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sourceServerResourceId": "str", - "state": "str", - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "str", - "storageSizeGB": 0, - "storageSku": "str", - }, - "version": "str", + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", }, + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "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", + } + ], + "replicaCapacity": 0, + "replicationRole": "str", + "restorePointInTime": "2020-02-20 00:00:00", "sku": {"name": "str", "tier": "str"}, + "sourceServerResourceId": "str", + "state": "str", + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "LocalRedundancy", + "storageSizeGB": 0, + "storageSku": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -144,7 +161,9 @@ def test_servers_begin_create(self, resource_group): }, "tags": {"str": "str"}, "type": "str", + "version": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -157,61 +176,60 @@ def test_servers_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ + "administratorLoginPassword": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "properties": { - "administratorLoginPassword": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "highAvailability": { - "mode": "str", - "replicationMode": "str", - "standbyAvailabilityZone": "str", - "state": "str", - }, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", - }, - "replicationRole": "str", - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "str", - "storageSizeGB": 0, - "storageSku": "str", - }, - "version": "str", + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", }, + "replicationRole": "str", "sku": {"name": "str", "tier": "str"}, + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "LocalRedundancy", + "storageSizeGB": 0, + "storageSku": "str", + }, "tags": {"str": "str"}, + "version": "str", }, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -223,6 +241,7 @@ 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="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -230,19 +249,14 @@ def test_servers_begin_delete(self, resource_group): @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( + def test_servers_begin_detach_v_net(self, resource_group): + response = self.client.servers.begin_detach_v_net( resource_group_name=resource_group.name, - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... + server_name="str", + parameters={"publicNetworkAccess": "str"}, + api_version="2025-06-01-preview", + ).result() # call '.result()' to poll until service return final result - @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 # ... @@ -252,6 +266,7 @@ def test_servers_begin_failover(self, resource_group): response = self.client.servers.begin_failover( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -259,16 +274,13 @@ def test_servers_begin_failover(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_servers_validate_estimate_high_availability(self, resource_group): - response = self.client.servers.validate_estimate_high_availability( + def test_servers_begin_reset_gtid(self, resource_group): + response = self.client.servers.begin_reset_gtid( resource_group_name=resource_group.name, server_name="str", - parameters={ - "estimatedDowntime": 0, - "expectedStandbyAvailabilityZone": "str", - "scheduledStandbyAvailabilityZone": "str", - }, - ) + parameters={"gtidSet": "str"}, + api_version="2025-06-01-preview", + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -280,6 +292,7 @@ def test_servers_begin_restart(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={"maxFailoverSeconds": 0, "restartWithFailover": "str"}, + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -291,6 +304,7 @@ def test_servers_begin_start(self, resource_group): response = self.client.servers.begin_start( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -302,6 +316,7 @@ def test_servers_begin_stop(self, resource_group): response = self.client.servers.begin_stop( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -309,24 +324,17 @@ def test_servers_begin_stop(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_servers_begin_reset_gtid(self, resource_group): - response = self.client.servers.begin_reset_gtid( - resource_group_name=resource_group.name, - server_name="str", - parameters={"gtidSet": "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_begin_detach_v_net(self, resource_group): - response = self.client.servers.begin_detach_v_net( + def test_servers_validate_estimate_high_availability(self, resource_group): + response = self.client.servers.validate_estimate_high_availability( resource_group_name=resource_group.name, server_name="str", - parameters={"publicNetworkAccess": "str"}, - ).result() # call '.result()' to poll until service return final result + parameters={ + "estimatedDowntime": 0, + "expectedStandbyAvailabilityZone": "str", + "scheduledStandbyAvailabilityZone": "str", + }, + api_version="2025-06-01-preview", + ) # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations_async.py b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations_async.py index fa5470f70906..1b5c3473506f 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_sql_management_servers_operations_async.py +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/generated_tests/test_my_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) Python Code Generator. +# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,12 +19,34 @@ class TestMySQLManagementServersOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(MySQLManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_list(self, resource_group): + response = self.client.servers.list( + api_version="2025-06-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="2025-06-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="2025-06-01-preview", ) # please add some check logic here by yourself @@ -39,6 +61,32 @@ async def test_servers_begin_create(self, resource_group): server_name="str", parameters={ "location": "str", + "administratorLogin": "str", + "administratorLoginPassword": "str", + "availabilityZone": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "createMode": "str", + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "databasePort": 0, + "fullVersion": "str", + "fullyQualifiedDomainName": "str", + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, "id": "str", "identity": { "principalId": "str", @@ -46,96 +94,65 @@ async def test_servers_begin_create(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, + "importSourceProperties": { + "dataDirPath": "str", + "sasToken": "str", + "storageType": "str", + "storageUrl": "str", + }, + "lowerCaseTableNames": 0, + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, "name": "str", - "properties": { - "administratorLogin": "str", - "administratorLoginPassword": "str", - "availabilityZone": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "createMode": "str", - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "databasePort": 0, - "fullVersion": "str", - "fullyQualifiedDomainName": "str", - "highAvailability": { - "mode": "str", - "replicationMode": "str", - "standbyAvailabilityZone": "str", - "state": "str", - }, - "importSourceProperties": { - "dataDirPath": "str", - "sasToken": "str", - "storageType": "str", - "storageUrl": "str", - }, - "lowerCaseTableNames": 0, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", - }, - "privateEndpointConnections": [ - { - "id": "str", - "name": "str", - "properties": { - "privateLinkServiceConnectionState": { - "actionsRequired": "str", - "description": "str", - "status": "str", - }, - "groupIds": ["str"], - "privateEndpoint": {"id": "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", - } - ], - "replicaCapacity": 0, - "replicationRole": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sourceServerResourceId": "str", - "state": "str", - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "str", - "storageSizeGB": 0, - "storageSku": "str", - }, - "version": "str", + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", }, + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "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", + } + ], + "replicaCapacity": 0, + "replicationRole": "str", + "restorePointInTime": "2020-02-20 00:00:00", "sku": {"name": "str", "tier": "str"}, + "sourceServerResourceId": "str", + "state": "str", + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "LocalRedundancy", + "storageSizeGB": 0, + "storageSku": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -146,7 +163,9 @@ async def test_servers_begin_create(self, resource_group): }, "tags": {"str": "str"}, "type": "str", + "version": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -161,61 +180,60 @@ async def test_servers_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ + "administratorLoginPassword": "str", + "backup": { + "backupIntervalHours": 0, + "backupRetentionDays": 0, + "earliestRestoreDate": "2020-02-20 00:00:00", + "geoRedundantBackup": "str", + }, + "dataEncryption": { + "geoBackupKeyURI": "str", + "geoBackupUserAssignedIdentityId": "str", + "primaryKeyURI": "str", + "primaryUserAssignedIdentityId": "str", + "type": "str", + }, + "highAvailability": { + "mode": "str", + "replicationMode": "str", + "standbyAvailabilityZone": "str", + "state": "str", + }, "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "properties": { - "administratorLoginPassword": "str", - "backup": { - "backupIntervalHours": 0, - "backupRetentionDays": 0, - "earliestRestoreDate": "2020-02-20 00:00:00", - "geoRedundantBackup": "str", - }, - "dataEncryption": { - "geoBackupKeyURI": "str", - "geoBackupUserAssignedIdentityId": "str", - "primaryKeyURI": "str", - "primaryUserAssignedIdentityId": "str", - "type": "str", - }, - "highAvailability": { - "mode": "str", - "replicationMode": "str", - "standbyAvailabilityZone": "str", - "state": "str", - }, - "maintenancePolicy": {"patchStrategy": "str"}, - "maintenanceWindow": { - "batchOfMaintenance": "str", - "customWindow": "str", - "dayOfWeek": 0, - "startHour": 0, - "startMinute": 0, - }, - "network": { - "delegatedSubnetResourceId": "str", - "privateDnsZoneResourceId": "str", - "publicNetworkAccess": "str", - }, - "replicationRole": "str", - "storage": { - "autoGrow": "str", - "autoIoScaling": "str", - "iops": 0, - "logOnDisk": "str", - "storageRedundancy": "str", - "storageSizeGB": 0, - "storageSku": "str", - }, - "version": "str", + "maintenancePolicy": {"patchStrategy": "str"}, + "maintenanceWindow": { + "batchOfMaintenance": "str", + "customWindow": "str", + "dayOfWeek": 0, + "startHour": 0, + "startMinute": 0, + }, + "network": { + "delegatedSubnetResourceId": "str", + "privateDnsZoneResourceId": "str", + "publicNetworkAccess": "str", }, + "replicationRole": "str", "sku": {"name": "str", "tier": "str"}, + "storage": { + "autoGrow": "str", + "autoIoScaling": "str", + "iops": 0, + "logOnDisk": "str", + "storageRedundancy": "LocalRedundancy", + "storageSizeGB": 0, + "storageSku": "str", + }, "tags": {"str": "str"}, + "version": "str", }, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -229,6 +247,7 @@ async def test_servers_begin_delete(self, resource_group): await self.client.servers.begin_delete( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -237,19 +256,16 @@ async def test_servers_begin_delete(self, resource_group): @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 - # ... + async def test_servers_begin_detach_v_net(self, resource_group): + response = await ( + await self.client.servers.begin_detach_v_net( + resource_group_name=resource_group.name, + server_name="str", + parameters={"publicNetworkAccess": "str"}, + api_version="2025-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result - @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 # ... @@ -260,6 +276,7 @@ async def test_servers_begin_failover(self, resource_group): await self.client.servers.begin_failover( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -268,16 +285,15 @@ async def test_servers_begin_failover(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_servers_validate_estimate_high_availability(self, resource_group): - response = await self.client.servers.validate_estimate_high_availability( - resource_group_name=resource_group.name, - server_name="str", - parameters={ - "estimatedDowntime": 0, - "expectedStandbyAvailabilityZone": "str", - "scheduledStandbyAvailabilityZone": "str", - }, - ) + async def test_servers_begin_reset_gtid(self, resource_group): + response = await ( + await self.client.servers.begin_reset_gtid( + resource_group_name=resource_group.name, + server_name="str", + parameters={"gtidSet": "str"}, + api_version="2025-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -290,6 +306,7 @@ async def test_servers_begin_restart(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={"maxFailoverSeconds": 0, "restartWithFailover": "str"}, + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -303,6 +320,7 @@ async def test_servers_begin_start(self, resource_group): await self.client.servers.begin_start( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -316,6 +334,7 @@ async def test_servers_begin_stop(self, resource_group): await self.client.servers.begin_stop( resource_group_name=resource_group.name, server_name="str", + api_version="2025-06-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -324,28 +343,17 @@ async def test_servers_begin_stop(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_servers_begin_reset_gtid(self, resource_group): - response = await ( - await self.client.servers.begin_reset_gtid( - resource_group_name=resource_group.name, - server_name="str", - parameters={"gtidSet": "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_begin_detach_v_net(self, resource_group): - response = await ( - await self.client.servers.begin_detach_v_net( - resource_group_name=resource_group.name, - server_name="str", - parameters={"publicNetworkAccess": "str"}, - ) - ).result() # call '.result()' to poll until service return final result + async def test_servers_validate_estimate_high_availability(self, resource_group): + response = await self.client.servers.validate_estimate_high_availability( + resource_group_name=resource_group.name, + server_name="str", + parameters={ + "estimatedDowntime": 0, + "expectedStandbyAvailabilityZone": "str", + "scheduledStandbyAvailabilityZone": "str", + }, + api_version="2025-06-01-preview", + ) # please add some check logic here by yourself # ... diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml index 082967ba81a2..896ece5cf7f5 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/pyproject.toml @@ -29,7 +29,7 @@ keywords = [ "azure sdk", ] dependencies = [ - "isodate>=0.6.1", + "msrest>=0.7.1", "azure-mgmt-core>=1.6.0", "typing-extensions>=4.6.0", ] diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml deleted file mode 100644 index 8360c1d67ad5..000000000000 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/tsp-location.yaml +++ /dev/null @@ -1,4 +0,0 @@ -directory: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers -commit: 1d3ac611f503e05650fb85520582b06140d2599e -repo: Azure/azure-rest-api-specs -additionalDirectories: From 1a35274d83437a48c256292b3ef3ef7c8f28f44e Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 Date: Wed, 19 Nov 2025 11:10:05 +0800 Subject: [PATCH 4/4] update changelog --- .../CHANGELOG.md | 75 +------------------ 1 file changed, 1 insertion(+), 74 deletions(-) diff --git a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md index 3452d0e5cca6..21084391b182 100644 --- a/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md +++ b/sdk/mysqlflexibleservers/azure-mgmt-mysqlflexibleservers/CHANGELOG.md @@ -8,80 +8,7 @@ - Model `Server` added property `lower_case_table_names` - Enum `ServerVersion` added member `EIGHT4` - Added enum `ReplicationMode` - - Model `LongRunningBackupOperations` added method `begin_delete` - -## 1.1.0b1 (2025-11-11) - -### Features Added - - - Model `MySQLManagementClient` added parameter `cloud_setting` in method `__init__` - - Client `MySQLManagementClient` added method `send_request` - - Client `MySQLManagementClient` added operation group `private_endpoint_connections` - - Client `MySQLManagementClient` added operation group `private_link_resources` - - Model `AzureADAdministrator` added property `properties` - - Model `Capability` added property `properties` - - Model `HighAvailability` added property `replication_mode` - - Model `MaintenanceWindow` added property `batch_of_maintenance` - - Model `OperationProgressResult` added property `properties` - - Model `ServerBackupV2` added property `properties` - - Model `ServerForUpdate` added property `properties` - - Enum `ServerVersion` added member `ENUM_8_4` - - Added model `AdministratorProperties` - - Added model `AdvancedThreatProtectionUpdateProperties` - - Added enum `BatchOfMaintenance` - - Added model `CapabilityPropertiesV2` - - Added model `MaintenancePropertiesForUpdate` - - Added enum `Origin` - - Added model `PrivateEndpointConnectionListResult` - - Added model `PrivateLinkResource` - - Added model `PrivateLinkResourceProperties` - - Added enum `ReplicationMode` - - Added model `ServerBackupPropertiesV2` - - Added model `ServerPropertiesForUpdate` - - Added model `ValidateBackupResponseProperties` - - Added operation group `PrivateEndpointConnectionsOperations` - - Added operation group `PrivateLinkResourcesOperations` - - Operation group `LongRunningBackupOperations` added method `begin_delete` - -### Breaking Changes - - - This version introduces new hybrid models which have dual dictionary and model nature. And please follow https://aka.ms/azsdk/python/migrate/hybrid-models for migration. - - For the method breakings, please refer to https://aka.ms/azsdk/python/migrate/operations for mgration. - - Model `AdvancedThreatProtectionForUpdate` deleted or renamed its instance variable `state` - - Model `AzureADAdministrator` deleted or renamed its instance variable `administrator_type` - - Model `AzureADAdministrator` deleted or renamed its instance variable `login` - - Model `AzureADAdministrator` deleted or renamed its instance variable `sid` - - Model `AzureADAdministrator` deleted or renamed its instance variable `tenant_id` - - Model `AzureADAdministrator` deleted or renamed its instance variable `identity_resource_id` - - Model `Capability` deleted or renamed its instance variable `supported_geo_backup_regions` - - Model `Capability` deleted or renamed its instance variable `supported_flexible_server_editions` - - Model `Capability` deleted or renamed its instance variable `supported_server_versions` - - Model `Capability` deleted or renamed its instance variable `supported_features` - - Model `MaintenanceUpdate` deleted or renamed its instance variable `maintenance_start_time` - - Model `OperationProgressResult` deleted or renamed its instance variable `object_type` - - Model `ServerBackupV2` deleted or renamed its instance variable `backup_name_v2` - - Model `ServerBackupV2` deleted or renamed its instance variable `backup_type` - - Model `ServerBackupV2` deleted or renamed its instance variable `completed_time` - - Model `ServerBackupV2` deleted or renamed its instance variable `source` - - Model `ServerBackupV2` deleted or renamed its instance variable `provisioning_state` - - Model `ServerForUpdate` deleted or renamed its instance variable `administrator_login_password` - - Model `ServerForUpdate` deleted or renamed its instance variable `version` - - Model `ServerForUpdate` deleted or renamed its instance variable `storage` - - Model `ServerForUpdate` deleted or renamed its instance variable `backup` - - Model `ServerForUpdate` deleted or renamed its instance variable `high_availability` - - Model `ServerForUpdate` deleted or renamed its instance variable `maintenance_policy` - - Model `ServerForUpdate` deleted or renamed its instance variable `maintenance_window` - - Model `ServerForUpdate` deleted or renamed its instance variable `replication_role` - - Model `ServerForUpdate` deleted or renamed its instance variable `data_encryption` - - Model `ServerForUpdate` deleted or renamed its instance variable `network` - - Model `ValidateBackupResponse` deleted or renamed its instance variable `number_of_containers` - - Deleted or renamed model `CapabilitySetsList` - - Deleted or renamed model `Provisioning` - - Method `ConfigurationsOperations.list_by_server` changed its parameter `tags` from `positional_or_keyword` to `keyword_only` - - Method `ConfigurationsOperations.list_by_server` changed its parameter `keyword` from `positional_or_keyword` to `keyword_only` - - Method `ConfigurationsOperations.list_by_server` changed its parameter `page` from `positional_or_keyword` to `keyword_only` - - Method `ConfigurationsOperations.list_by_server` changed its parameter `page_size` from `positional_or_keyword` to `keyword_only` - - Method `LocationBasedCapabilitySetOperations.get` removed default value `None` from its parameter `capability_set_name` + - Operation group `LongRunningBackupOperations` added method `begin_delete` ## 1.0.0 (2025-11-07)