From 887a2ea85aed15ac509b879084885c205118fb04 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 12 May 2025 18:28:24 +0000 Subject: [PATCH] CodeGen from PR 33867 in Azure/azure-rest-api-specs Merge ab9157b51cac68f741cfaaeec078ec8e4f6bfd59 into e489de297e262f087de27000a48dd69417e345a4 --- sdk/cdn/azure-mgmt-cdn/CHANGELOG.md | 69 + sdk/cdn/azure-mgmt-cdn/README.md | 6 +- sdk/cdn/azure-mgmt-cdn/_meta.json | 6 +- .../azure-mgmt-cdn/azure/mgmt/cdn/__init__.py | 12 +- .../azure/mgmt/cdn/_cdn_management_client.py | 34 +- .../azure/mgmt/cdn/_configuration.py | 7 +- .../azure/mgmt/cdn/_utils/__init__.py | 6 + .../serialization.py} | 568 ++++--- .../cdn/{aio/_vendor.py => _utils/utils.py} | 19 +- .../azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py | 36 - .../azure-mgmt-cdn/azure/mgmt/cdn/_version.py | 2 +- .../azure/mgmt/cdn/aio/__init__.py | 12 +- .../mgmt/cdn/aio/_cdn_management_client.py | 36 +- .../azure/mgmt/cdn/aio/_configuration.py | 7 +- .../azure/mgmt/cdn/aio/operations/__init__.py | 54 +- .../_afd_custom_domains_operations.py | 173 +- .../operations/_afd_endpoints_operations.py | 207 +-- .../_afd_origin_groups_operations.py | 152 +- .../aio/operations/_afd_origins_operations.py | 144 +- .../operations/_afd_profiles_operations.py | 84 +- .../_cdn_management_client_operations.py | 40 +- .../operations/_custom_domains_operations.py | 125 +- .../aio/operations/_edge_nodes_operations.py | 29 +- .../aio/operations/_endpoints_operations.py | 212 +-- .../operations/_log_analytics_operations.py | 55 +- .../_managed_rule_sets_operations.py | 29 +- .../mgmt/cdn/aio/operations/_operations.py | 29 +- .../operations/_origin_groups_operations.py | 108 +- .../cdn/aio/operations/_origins_operations.py | 108 +- .../aio/operations/_policies_operations.py | 91 +- .../aio/operations/_profiles_operations.py | 637 ++++++-- .../operations/_resource_usage_operations.py | 29 +- .../cdn/aio/operations/_routes_operations.py | 144 +- .../aio/operations/_rule_sets_operations.py | 94 +- .../cdn/aio/operations/_rules_operations.py | 144 +- .../cdn/aio/operations/_secrets_operations.py | 110 +- .../_security_policies_operations.py | 144 +- .../azure/mgmt/cdn/models/__init__.py | 847 +++++----- .../models/_cdn_management_client_enums.py | 280 ++-- .../azure/mgmt/cdn/models/_models_py3.py | 1431 +++++++++++------ .../azure/mgmt/cdn/operations/__init__.py | 54 +- .../_afd_custom_domains_operations.py | 222 +-- .../operations/_afd_endpoints_operations.py | 271 ++-- .../_afd_origin_groups_operations.py | 201 +-- .../cdn/operations/_afd_origins_operations.py | 185 ++- .../operations/_afd_profiles_operations.py | 113 +- .../_cdn_management_client_operations.py | 51 +- .../operations/_custom_domains_operations.py | 150 +- .../cdn/operations/_edge_nodes_operations.py | 31 +- .../cdn/operations/_endpoints_operations.py | 256 +-- .../operations/_log_analytics_operations.py | 80 +- .../_managed_rule_sets_operations.py | 33 +- .../azure/mgmt/cdn/operations/_operations.py | 31 +- .../operations/_origin_groups_operations.py | 129 +- .../cdn/operations/_origins_operations.py | 129 +- .../cdn/operations/_policies_operations.py | 107 +- .../cdn/operations/_profiles_operations.py | 784 +++++++-- .../operations/_resource_usage_operations.py | 31 +- .../mgmt/cdn/operations/_routes_operations.py | 185 ++- .../cdn/operations/_rule_sets_operations.py | 135 +- .../mgmt/cdn/operations/_rules_operations.py | 185 ++- .../cdn/operations/_secrets_operations.py | 143 +- .../_security_policies_operations.py | 185 ++- .../afd_custom_domains_create.py | 15 +- .../afd_custom_domains_delete.py | 3 +- .../afd_custom_domains_get.py | 3 +- .../afd_custom_domains_list_by_profile.py | 3 +- ...custom_domains_refresh_validation_token.py | 3 +- .../afd_custom_domains_update.py | 15 +- .../generated_samples/afd_endpoints_create.py | 5 +- .../generated_samples/afd_endpoints_delete.py | 3 +- .../generated_samples/afd_endpoints_get.py | 2 +- .../afd_endpoints_list_by_profile.py | 3 +- .../afd_endpoints_list_resource_usage.py | 3 +- .../afd_endpoints_purge_content.py | 5 +- .../generated_samples/afd_endpoints_update.py | 5 +- .../afd_endpoints_validate_custom_domain.py | 5 +- .../afd_origin_groups_create.py | 5 +- .../afd_origin_groups_delete.py | 3 +- .../afd_origin_groups_get.py | 3 +- .../afd_origin_groups_list_by_profile.py | 3 +- .../afd_origin_groups_list_resource_usage.py | 3 +- .../afd_origin_groups_update.py | 5 +- .../generated_samples/afd_origins_create.py | 4 +- .../generated_samples/afd_origins_delete.py | 2 +- .../generated_samples/afd_origins_get.py | 2 +- .../afd_origins_list_by_origin_group.py | 3 +- .../generated_samples/afd_origins_update.py | 4 +- ...ofiles_check_endpoint_name_availability.py | 5 +- ...d_profiles_check_host_name_availability.py | 5 +- .../afd_profiles_list_resource_usage.py | 3 +- .../generated_samples/afd_profiles_upgrade.py | 5 +- .../afd_profiles_validate_secret.py | 5 +- .../cdn_profiles_can_migrate.py | 43 + .../generated_samples/cdn_profiles_migrate.py | 44 + .../check_endpoint_name_availability.py | 5 +- .../check_name_availability.py | 5 +- ...eck_name_availability_with_subscription.py | 5 +- .../custom_domains_create.py | 5 +- .../custom_domains_delete.py | 3 +- .../custom_domains_disable_custom_https.py | 3 +- ..._domains_enable_custom_https_using_byoc.py | 3 +- ...tom_https_using_cdn_managed_certificate.py | 3 +- .../generated_samples/custom_domains_get.py | 2 +- .../custom_domains_list_by_endpoint.py | 3 +- .../generated_samples/edge_nodes_list.py | 2 +- .../generated_samples/endpoints_create.py | 5 +- .../generated_samples/endpoints_delete.py | 2 +- .../generated_samples/endpoints_get.py | 2 +- .../endpoints_list_by_profile.py | 3 +- .../endpoints_list_resource_usage.py | 3 +- .../endpoints_load_content.py | 5 +- .../endpoints_purge_content.py | 5 +- .../generated_samples/endpoints_start.py | 2 +- .../generated_samples/endpoints_stop.py | 2 +- .../generated_samples/endpoints_update.py | 4 +- .../endpoints_validate_custom_domain.py | 5 +- ...g_analytics_get_log_analytics_locations.py | 3 +- ...log_analytics_get_log_analytics_metrics.py | 8 +- ...og_analytics_get_log_analytics_rankings.py | 8 +- ...g_analytics_get_log_analytics_resources.py | 3 +- ...analytics_get_waf_log_analytics_metrics.py | 8 +- ...nalytics_get_waf_log_analytics_rankings.py | 8 +- .../generated_samples/operations_list.py | 2 +- .../generated_samples/origin_groups_create.py | 5 +- .../generated_samples/origin_groups_delete.py | 3 +- .../generated_samples/origin_groups_get.py | 2 +- .../origin_groups_list_by_endpoint.py | 3 +- .../generated_samples/origin_groups_update.py | 5 +- .../generated_samples/origins_create.py | 5 +- .../generated_samples/origins_delete.py | 2 +- .../generated_samples/origins_get.py | 2 +- .../origins_list_by_endpoint.py | 3 +- .../generated_samples/origins_update.py | 4 +- .../generated_samples/profiles_can_migrate.py | 5 +- .../generated_samples/profiles_create.py | 4 +- .../generated_samples/profiles_delete.py | 2 +- .../profiles_generate_sso_uri.py | 3 +- .../generated_samples/profiles_get.py | 2 +- .../generated_samples/profiles_list.py | 2 +- .../profiles_list_by_resource_group.py | 3 +- .../profiles_list_resource_usage.py | 3 +- ...files_list_supported_optimization_types.py | 3 +- .../generated_samples/profiles_migrate.py | 4 +- .../profiles_migration_abort.py | 42 + .../profiles_migration_commit.py | 3 +- .../generated_samples/profiles_update.py | 4 +- .../generated_samples/resource_usage_list.py | 3 +- .../generated_samples/routes_create.py | 5 +- .../generated_samples/routes_delete.py | 2 +- .../generated_samples/routes_get.py | 2 +- .../routes_list_by_endpoint.py | 3 +- .../generated_samples/routes_update.py | 5 +- .../generated_samples/rule_sets_create.py | 2 +- .../generated_samples/rule_sets_delete.py | 2 +- .../generated_samples/rule_sets_get.py | 2 +- .../rule_sets_list_by_profile.py | 3 +- .../rule_sets_list_resource_usage.py | 3 +- .../generated_samples/rules_create.py | 4 +- .../generated_samples/rules_delete.py | 2 +- .../generated_samples/rules_get.py | 2 +- .../rules_list_by_rule_set.py | 3 +- .../generated_samples/rules_update.py | 4 +- .../generated_samples/secrets_create.py | 5 +- .../generated_samples/secrets_delete.py | 2 +- .../generated_samples/secrets_get.py | 2 +- .../secrets_list_by_profile.py | 3 +- .../security_policies_create.py | 5 +- .../security_policies_delete.py | 3 +- .../security_policies_get.py | 3 +- .../security_policies_list_by_profile.py | 3 +- .../security_policies_patch.py | 5 +- .../generated_samples/validate_probe.py | 4 +- .../waf_list_managed_rule_sets.py | 3 +- .../generated_samples/waf_list_policies.py | 2 +- .../generated_samples/waf_patch_policy.py | 4 +- .../waf_policy_create_or_update.py | 5 +- .../generated_samples/waf_policy_delete.py | 2 +- .../generated_samples/waf_policy_get.py | 2 +- .../generated_tests/conftest.py | 35 + .../generated_tests/test_cdn_management.py | 68 + ...anagement_afd_custom_domains_operations.py | 137 ++ ...ent_afd_custom_domains_operations_async.py | 152 ++ ...cdn_management_afd_endpoints_operations.py | 146 ++ ...nagement_afd_endpoints_operations_async.py | 155 ++ ...management_afd_origin_groups_operations.py | 141 ++ ...ment_afd_origin_groups_operations_async.py | 148 ++ ...t_cdn_management_afd_origins_operations.py | 139 ++ ...management_afd_origins_operations_async.py | 146 ++ ..._cdn_management_afd_profiles_operations.py | 89 + ...anagement_afd_profiles_operations_async.py | 92 ++ .../test_cdn_management_async.py | 69 + ...dn_management_custom_domains_operations.py | 103 ++ ...agement_custom_domains_operations_async.py | 112 ++ ...st_cdn_management_edge_nodes_operations.py | 29 + ..._management_edge_nodes_operations_async.py | 30 + ...est_cdn_management_endpoints_operations.py | 293 ++++ ...n_management_endpoints_operations_async.py | 308 ++++ ...cdn_management_log_analytics_operations.py | 111 ++ ...nagement_log_analytics_operations_async.py | 112 ++ ...management_managed_rule_sets_operations.py | 29 + ...ment_managed_rule_sets_operations_async.py | 30 + .../test_cdn_management_operations.py | 29 + .../test_cdn_management_operations_async.py | 30 + ...cdn_management_origin_groups_operations.py | 131 ++ ...nagement_origin_groups_operations_async.py | 138 ++ .../test_cdn_management_origins_operations.py | 128 ++ ...cdn_management_origins_operations_async.py | 135 ++ ...test_cdn_management_policies_operations.py | 164 ++ ...dn_management_policies_operations_async.py | 169 ++ ...test_cdn_management_profiles_operations.py | 257 +++ ...dn_management_profiles_operations_async.py | 276 ++++ ...dn_management_resource_usage_operations.py | 29 + ...agement_resource_usage_operations_async.py | 30 + .../test_cdn_management_routes_operations.py | 137 ++ ..._cdn_management_routes_operations_async.py | 144 ++ ...est_cdn_management_rule_sets_operations.py | 83 + ...n_management_rule_sets_operations_async.py | 86 + .../test_cdn_management_rules_operations.py | 115 ++ ...t_cdn_management_rules_operations_async.py | 122 ++ .../test_cdn_management_secrets_operations.py | 87 + ...cdn_management_secrets_operations_async.py | 92 ++ ...management_security_policies_operations.py | 101 ++ ...ment_security_policies_operations_async.py | 108 ++ sdk/cdn/azure-mgmt-cdn/setup.py | 6 +- 225 files changed, 11372 insertions(+), 4461 deletions(-) create mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/__init__.py rename sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/{_serialization.py => _utils/serialization.py} (83%) rename sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/{aio/_vendor.py => _utils/utils.py} (59%) delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_can_migrate.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_migrate.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_abort.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/conftest.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py diff --git a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md index d3fbb1381f6d..7d57899e0211 100644 --- a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md +++ b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md @@ -1,5 +1,74 @@ # Release History +## 14.0.0 (2025-05-12) + +### Features Added + + - Model `AFDDomainHttpsParameters` added property `cipher_suite_set_type` + - Model `AFDDomainHttpsParameters` added property `customized_cipher_suite_set` + - Enum `AfdMinimumTlsVersion` added member `TLS13` + - Enum `MatchProcessingBehavior` added member `CONTINUE` + - Added model `AFDDomainHttpsCustomizedCipherSuiteSet` + - Added enum `AfdCipherSuiteSetType` + - Added enum `AfdCustomizedCipherSuiteForTls12` + - Added enum `AfdCustomizedCipherSuiteForTls13` + - Added model `CdnMigrationToAfdParameters` + - Added model `CertificateSourceParameters` + - Added enum `CertificateSourceParametersType` + - Added model `DeliveryRuleActionParameters` + - Added enum `DeliveryRuleActionParametersType` + - Added model `DeliveryRuleConditionParameters` + - Added enum `DeliveryRuleConditionParametersType` + - Added model `ErrorResponseAutoGenerated` + - Added enum `IsDeviceMatchValue` + - Added enum `KeyVaultSigningKeyParametersType` + - Added model `MigrationEndpointMapping` + - Added enum `RequestMethodMatchValue` + - Added enum `RequestSchemeMatchValue` + - Model `ProfilesOperations` added method `begin_cdn_can_migrate_to_afd` + - Model `ProfilesOperations` added method `begin_cdn_migrate_to_afd` + - Model `ProfilesOperations` added method `begin_migration_abort` + - Method `ProfilesOperations.begin_cdn_migrate_to_afd` has a new overload `def begin_cdn_migrate_to_afd(self: None, resource_group_name: str, profile_name: str, migration_parameters: CdnMigrationToAfdParameters, content_type: str)` + - Method `ProfilesOperations.begin_cdn_migrate_to_afd` has a new overload `def begin_cdn_migrate_to_afd(self: None, resource_group_name: str, profile_name: str, migration_parameters: IO[bytes], content_type: str)` + +### Breaking Changes + + - Deleted or renamed enum value `MatchProcessingBehavior.CONTINUE_ENUM` + - Method `UrlSigningKeyParameters.__init__` removed default value `None` from its parameter `secret_version` + - Deleted or renamed model `CacheExpirationActionParametersTypeName` + - Deleted or renamed model `CacheKeyQueryStringActionParametersTypeName` + - Deleted or renamed model `CdnCertificateSourceParametersTypeName` + - Deleted or renamed model `ClientPortMatchConditionParametersTypeName` + - Deleted or renamed model `CookiesMatchConditionParametersTypeName` + - Deleted or renamed model `HeaderActionParametersTypeName` + - Deleted or renamed model `HostNameMatchConditionParametersTypeName` + - Deleted or renamed model `HttpVersionMatchConditionParametersTypeName` + - Deleted or renamed model `IsDeviceMatchConditionParametersMatchValuesItem` + - Deleted or renamed model `IsDeviceMatchConditionParametersTypeName` + - Deleted or renamed model `KeyVaultCertificateSourceParametersTypeName` + - Deleted or renamed model `KeyVaultSigningKeyParametersTypeName` + - Deleted or renamed model `OriginGroupOverrideActionParametersTypeName` + - Deleted or renamed model `PostArgsMatchConditionParametersTypeName` + - Deleted or renamed model `QueryStringMatchConditionParametersTypeName` + - Deleted or renamed model `RemoteAddressMatchConditionParametersTypeName` + - Deleted or renamed model `RequestBodyMatchConditionParametersTypeName` + - Deleted or renamed model `RequestHeaderMatchConditionParametersTypeName` + - Deleted or renamed model `RequestMethodMatchConditionParametersMatchValuesItem` + - Deleted or renamed model `RequestMethodMatchConditionParametersTypeName` + - Deleted or renamed model `RequestSchemeMatchConditionParametersMatchValuesItem` + - Deleted or renamed model `RequestSchemeMatchConditionParametersTypeName` + - Deleted or renamed model `RequestUriMatchConditionParametersTypeName` + - Deleted or renamed model `RouteConfigurationOverrideActionParametersTypeName` + - Deleted or renamed model `ServerPortMatchConditionParametersTypeName` + - Deleted or renamed model `SocketAddrMatchConditionParametersTypeName` + - Deleted or renamed model `SslProtocolMatchConditionParametersTypeName` + - Deleted or renamed model `UrlFileExtensionMatchConditionParametersTypeName` + - Deleted or renamed model `UrlFileNameMatchConditionParametersTypeName` + - Deleted or renamed model `UrlPathMatchConditionParametersTypeName` + - Deleted or renamed model `UrlRedirectActionParametersTypeName` + - Deleted or renamed model `UrlRewriteActionParametersTypeName` + - Deleted or renamed model `UrlSigningActionParametersTypeName` + ## 13.1.1 (2024-06-12) ### Bugs Fixed diff --git a/sdk/cdn/azure-mgmt-cdn/README.md b/sdk/cdn/azure-mgmt-cdn/README.md index 6aa59315c876..b837ae8bc943 100644 --- a/sdk/cdn/azure-mgmt-cdn/README.md +++ b/sdk/cdn/azure-mgmt-cdn/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure CDN Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/cdn/azure-mgmt-cdn/_meta.json b/sdk/cdn/azure-mgmt-cdn/_meta.json index a5cd8e2186b3..542ac38ca55b 100644 --- a/sdk/cdn/azure-mgmt-cdn/_meta.json +++ b/sdk/cdn/azure-mgmt-cdn/_meta.json @@ -1,11 +1,11 @@ { - "commit": "de1f3772629b6f4d3ac01548a5f6d719bfb97c9e", + "commit": "1485122b325dcb50ea795367c16f055a9129386c", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.19", + "@autorest/python@6.34.1", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/cdn/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.19 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/cdn/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.34.1 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/cdn/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/__init__.py index be3eb8d20d1d..333e59422592 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/__init__.py @@ -5,15 +5,21 @@ # 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 -from ._cdn_management_client import CdnManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._cdn_management_client import CdnManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "CdnManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py index 99307737ccda..f4c9b664c10b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py @@ -7,16 +7,19 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from . import models as _models from ._configuration import CdnManagementClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( AFDCustomDomainsOperations, AFDEndpointsOperations, @@ -43,13 +46,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class CdnManagementClient( - CdnManagementClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class CdnManagementClient(CdnManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Cdn Management Client. :ivar afd_profiles: AFDProfilesOperations operations @@ -98,9 +98,9 @@ class CdnManagementClient( :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2025-04-15". 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 @@ -108,15 +108,17 @@ class CdnManagementClient( """ def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = CdnManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -135,7 +137,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -196,7 +198,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "CdnManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py index 42db4d3db8e6..203a8da4b47e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for CdnManagementClient. Note that all parameters used to create this instance are saved as instance @@ -28,13 +27,13 @@ class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-att :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2025-04-15". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-02-01") + api_version: str = kwargs.pop("api_version", "2025-04-15") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/__init__.py new file mode 100644 index 000000000000..0af9b28f6607 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/__init__.py @@ -0,0 +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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/serialization.py similarity index 83% rename from sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py rename to sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/serialization.py index f0c6180722c8..f5187701d7be 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/serialization.py @@ -1,30 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -48,11 +30,8 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, - Mapping, ) try: @@ -62,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +70,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +93,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -144,6 +125,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,6 +136,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -177,80 +165,31 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -298,13 +244,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -324,7 +280,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -344,7 +304,9 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, @@ -378,12 +340,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -393,30 +358,31 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -424,9 +390,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -446,21 +414,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -499,11 +471,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -538,7 +512,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -558,13 +532,16 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -590,12 +567,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -631,7 +610,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -662,17 +642,17 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) raise SerializationError(msg) from err - else: - return serialized + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -701,7 +681,7 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: raise SerializationError("Unable to build a model: " + str(err)) from err @@ -710,11 +690,13 @@ def body(self, data, data_type, **kwargs): def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -726,21 +708,20 @@ def url(self, name, data, data_type, **kwargs): output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator @@ -757,19 +738,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -778,21 +760,20 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") @@ -803,7 +784,7 @@ def serialize_data(self, data, data_type, **kwargs): if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -819,11 +800,10 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -839,23 +819,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -869,8 +852,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -880,15 +862,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -943,9 +923,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -969,7 +948,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -977,6 +956,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -1001,7 +981,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1032,56 +1012,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1089,11 +1074,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1103,30 +1089,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1139,12 +1127,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1170,13 +1159,14 @@ def serialize_iso(attr, **kwargs): raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1184,11 +1174,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1209,7 +1199,9 @@ def rest_key_extractor(attr, attr_desc, data): return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1230,17 +1222,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1277,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1329,22 +1333,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1352,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1361,9 +1364,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - 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_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1399,27 +1402,29 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1438,13 +1443,13 @@ def _deserialize(self, target_obj, data): if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1474,9 +1479,8 @@ def _deserialize(self, target_obj, data): except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1503,6 +1507,8 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None @@ -1514,7 +1520,7 @@ def _classify_target(self, target, data): return target, target try: - target = target._classify(data, self.dependencies) # type: ignore + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1529,10 +1535,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1550,10 +1558,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1577,24 +1587,35 @@ def _unpack_content(raw_data, content_type=None): def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1603,15 +1624,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1625,7 +1647,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1645,14 +1671,14 @@ def deserialize_data(self, data, data_type): msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1669,6 +1695,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1679,13 +1706,14 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1718,11 +1746,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1730,8 +1757,9 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1741,24 +1769,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, str): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1766,6 +1793,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1779,8 +1807,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1792,6 +1819,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1802,9 +1830,9 @@ def deserialize_enum(data, enum_obj): # Workaround. We might consider remove it in the future. try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1820,8 +1848,9 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1832,8 +1861,9 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1847,8 +1877,9 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text @@ -1863,8 +1894,9 @@ def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1875,8 +1907,9 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1885,16 +1918,16 @@ def deserialize_duration(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise DeserializationError(msg) from err - else: - return duration + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1908,8 +1941,9 @@ def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1922,31 +1956,32 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1974,8 +2009,7 @@ def deserialize_iso(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_unix(attr): @@ -1983,8 +2017,9 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore @@ -1994,5 +2029,4 @@ def deserialize_unix(attr): except ValueError as err: msg = "Cannot deserialize to unix datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_vendor.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/utils.py similarity index 59% rename from sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_vendor.py rename to sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/utils.py index 2fc2afd41b44..39b612f39a9b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_vendor.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/utils.py @@ -6,23 +6,20 @@ # -------------------------------------------------------------------------- from abc import ABC -from typing import TYPE_CHECKING - -from azure.core.pipeline.transport import HttpRequest - -from ._configuration import CdnManagementClientConfiguration +from typing import Generic, TYPE_CHECKING, TypeVar if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import AsyncPipelineClient + from .serialization import Deserializer, Serializer + - from .._serialization import Deserializer, Serializer +TClient = TypeVar("TClient") +TConfig = TypeVar("TConfig") -class CdnManagementClientMixinABC(ABC): +class ClientMixinABC(ABC, Generic[TClient, TConfig]): """DO NOT use this class. It is for internal typing use only.""" - _client: "AsyncPipelineClient" - _config: CdnManagementClientConfiguration + _client: TClient + _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py deleted file mode 100644 index 7f38712a5635..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py +++ /dev/null @@ -1,36 +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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from azure.core.pipeline.transport import HttpRequest - -from ._configuration import CdnManagementClientConfiguration - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -class CdnManagementClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: CdnManagementClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py index ac7454afbab4..5e2af93ed464 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.1.1" +VERSION = "14.0.0" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/__init__.py index ca0d8662c45f..e1b8503a3b09 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/__init__.py @@ -5,12 +5,18 @@ # 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 -from ._cdn_management_client import CdnManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._cdn_management_client import CdnManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "CdnManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py index d0f896981425..b2cc3906b5f0 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py @@ -7,15 +7,18 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import CdnManagementClientConfiguration from .operations import ( AFDCustomDomainsOperations, @@ -43,13 +46,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class CdnManagementClient( - CdnManagementClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class CdnManagementClient(CdnManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Cdn Management Client. :ivar afd_profiles: AFDProfilesOperations operations @@ -98,9 +98,9 @@ class CdnManagementClient( :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2025-04-15". 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 @@ -108,15 +108,17 @@ class CdnManagementClient( """ def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = CdnManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -135,7 +137,9 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs + ) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -198,7 +202,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "CdnManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py index 7c40851bb371..656f6debd84b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for CdnManagementClient. Note that all parameters used to create this instance are saved as instance @@ -28,13 +27,13 @@ class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-att :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2025-04-15". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-02-01") + api_version: str = kwargs.pop("api_version", "2025-04-15") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/__init__.py index ebcf7eb37437..5e05549bd0b7 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/__init__.py @@ -5,32 +5,38 @@ # 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 -from ._cdn_management_client_operations import CdnManagementClientOperationsMixin -from ._afd_profiles_operations import AFDProfilesOperations -from ._afd_custom_domains_operations import AFDCustomDomainsOperations -from ._afd_endpoints_operations import AFDEndpointsOperations -from ._afd_origin_groups_operations import AFDOriginGroupsOperations -from ._afd_origins_operations import AFDOriginsOperations -from ._routes_operations import RoutesOperations -from ._rule_sets_operations import RuleSetsOperations -from ._rules_operations import RulesOperations -from ._security_policies_operations import SecurityPoliciesOperations -from ._secrets_operations import SecretsOperations -from ._log_analytics_operations import LogAnalyticsOperations -from ._profiles_operations import ProfilesOperations -from ._endpoints_operations import EndpointsOperations -from ._origins_operations import OriginsOperations -from ._origin_groups_operations import OriginGroupsOperations -from ._custom_domains_operations import CustomDomainsOperations -from ._resource_usage_operations import ResourceUsageOperations -from ._operations import Operations -from ._edge_nodes_operations import EdgeNodesOperations -from ._policies_operations import PoliciesOperations -from ._managed_rule_sets_operations import ManagedRuleSetsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._cdn_management_client_operations import CdnManagementClientOperationsMixin # type: ignore +from ._afd_profiles_operations import AFDProfilesOperations # type: ignore +from ._afd_custom_domains_operations import AFDCustomDomainsOperations # type: ignore +from ._afd_endpoints_operations import AFDEndpointsOperations # type: ignore +from ._afd_origin_groups_operations import AFDOriginGroupsOperations # type: ignore +from ._afd_origins_operations import AFDOriginsOperations # type: ignore +from ._routes_operations import RoutesOperations # type: ignore +from ._rule_sets_operations import RuleSetsOperations # type: ignore +from ._rules_operations import RulesOperations # type: ignore +from ._security_policies_operations import SecurityPoliciesOperations # type: ignore +from ._secrets_operations import SecretsOperations # type: ignore +from ._log_analytics_operations import LogAnalyticsOperations # type: ignore +from ._profiles_operations import ProfilesOperations # type: ignore +from ._endpoints_operations import EndpointsOperations # type: ignore +from ._origins_operations import OriginsOperations # type: ignore +from ._origin_groups_operations import OriginGroupsOperations # type: ignore +from ._custom_domains_operations import CustomDomainsOperations # type: ignore +from ._resource_usage_operations import ResourceUsageOperations # type: ignore +from ._operations import Operations # type: ignore +from ._edge_nodes_operations import EdgeNodesOperations # type: ignore +from ._policies_operations import PoliciesOperations # type: ignore +from ._managed_rule_sets_operations import ManagedRuleSetsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -57,5 +63,5 @@ "PoliciesOperations", "ManagedRuleSetsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py index 92e5deeb37d6..36c009ce2e8b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._afd_custom_domains_operations import ( build_create_request, build_delete_request, @@ -40,12 +41,8 @@ build_refresh_validation_token_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,10 +61,10 @@ class AFDCustomDomainsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -77,8 +74,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either AFDDomain or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDDomain] @@ -90,7 +87,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDDomainListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,7 +106,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +121,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,8 +159,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -174,7 +169,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.AFDDomain :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +192,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -212,7 +206,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -226,8 +220,8 @@ async def _create_initial( custom_domain_name: str, custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -240,7 +234,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -262,10 +256,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -273,21 +267,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 201: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -309,8 +301,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -341,8 +333,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -371,8 +363,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -407,10 +399,11 @@ async def begin_create( 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("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -442,8 +435,8 @@ async def _update_initial( custom_domain_name: str, custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -456,7 +449,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -478,10 +471,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -489,18 +482,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -522,8 +516,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -554,8 +548,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -584,8 +578,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -621,10 +615,11 @@ async def begin_update( 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("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -649,10 +644,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -664,7 +659,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -675,10 +670,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -686,6 +681,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -694,8 +693,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -706,8 +709,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -725,7 +728,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -735,6 +738,7 @@ async def begin_delete( 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 @@ -759,10 +763,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements + async def _refresh_validation_token_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -774,7 +778,7 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_refresh_validation_token_request( resource_group_name=resource_group_name, @@ -785,10 +789,10 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -796,6 +800,10 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -804,8 +812,12 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_refresh_validation_token( @@ -815,8 +827,8 @@ async def begin_refresh_validation_token( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -834,7 +846,7 @@ async def begin_refresh_validation_token( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_validation_token_initial( # type: ignore + raw_result = await self._refresh_validation_token_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -844,6 +856,7 @@ async def begin_refresh_validation_token( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py index d9fde2ce9580..6bb30d60fdf8 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +6,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +19,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +33,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._afd_endpoints_operations import ( build_create_request, build_delete_request, @@ -42,12 +44,8 @@ build_update_request, build_validate_custom_domain_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,10 +64,10 @@ class AFDEndpointsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -79,8 +77,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDEndpoint] @@ -92,7 +90,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDEndpointListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,7 +109,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -127,7 +124,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -166,8 +162,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -176,7 +172,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.AFDEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,7 +195,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -214,7 +209,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -228,8 +223,8 @@ async def _create_initial( endpoint_name: str, endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,7 +237,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -264,10 +259,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -275,21 +270,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -312,8 +305,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -345,8 +338,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -376,8 +369,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -412,10 +405,11 @@ async def begin_create( 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("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -447,8 +441,8 @@ async def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,7 +455,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -483,10 +477,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -494,18 +488,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -530,8 +525,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -565,8 +560,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -598,8 +593,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -635,10 +630,11 @@ async def begin_update( 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("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -663,10 +659,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -678,7 +674,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -689,10 +685,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -700,6 +696,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -708,8 +708,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -720,8 +724,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -739,7 +743,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -749,6 +753,7 @@ async def begin_delete( 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 @@ -773,15 +778,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _purge_content_initial( # pylint: disable=inconsistent-return-statements + async def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -794,7 +799,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -816,10 +821,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -827,6 +832,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -835,8 +844,12 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_purge_content( @@ -853,8 +866,8 @@ async def begin_purge_content( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -887,8 +900,8 @@ async def begin_purge_content( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -919,8 +932,8 @@ async def begin_purge_content( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -944,7 +957,7 @@ async def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._purge_content_initial( # type: ignore + raw_result = await self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -956,6 +969,7 @@ async def begin_purge_content( 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 @@ -988,8 +1002,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1004,7 +1018,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1024,7 +1038,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1040,7 +1053,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1086,8 +1098,8 @@ async def validate_custom_domain( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1118,8 +1130,8 @@ async def validate_custom_domain( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1148,8 +1160,8 @@ async def validate_custom_domain( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1161,7 +1173,7 @@ async def validate_custom_domain( :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1196,7 +1208,6 @@ async def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1211,7 +1222,7 @@ async def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py index c40286f25555..55a1f318d54d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._afd_origin_groups_operations import ( build_create_request, build_delete_request, @@ -40,12 +41,8 @@ build_list_resource_usage_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,10 +61,10 @@ class AFDOriginGroupsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -77,8 +74,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -90,7 +87,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOriginGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,7 +106,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +121,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -163,8 +158,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -173,7 +168,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -196,7 +191,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -211,7 +205,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -225,8 +219,8 @@ async def _create_initial( origin_group_name: str, origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,7 +233,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -261,10 +255,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -272,21 +266,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -308,8 +300,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -340,8 +332,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -370,8 +362,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -406,10 +398,11 @@ async def begin_create( 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("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -441,8 +434,8 @@ async def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -455,7 +448,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -477,10 +470,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -488,18 +481,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -521,8 +515,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -553,8 +547,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -583,8 +577,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -620,10 +614,11 @@ async def begin_update( 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("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -648,10 +643,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -663,7 +658,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -674,10 +669,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -685,6 +680,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -693,8 +692,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -704,8 +707,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -723,7 +726,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -733,6 +736,7 @@ async def begin_delete( 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 @@ -765,8 +769,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -781,7 +785,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -801,7 +805,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -817,7 +820,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py index 49f79d669942..0a032b24ed4d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._afd_origins_operations import ( build_create_request, build_delete_request, @@ -39,12 +40,8 @@ build_list_by_origin_group_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +60,10 @@ class AFDOriginsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_origin_group( @@ -76,8 +73,8 @@ def list_by_origin_group( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -92,7 +89,7 @@ def list_by_origin_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOriginListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,7 +109,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +124,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -166,8 +161,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -178,7 +173,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.AFDOrigin :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -202,7 +197,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,7 +211,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -232,8 +226,8 @@ async def _create_initial( origin_name: str, origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,7 +240,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -269,10 +263,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -280,21 +274,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -317,8 +309,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -352,8 +344,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -385,8 +377,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -423,10 +415,11 @@ async def begin_create( 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("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -459,8 +452,8 @@ async def _update_initial( origin_name: str, origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,7 +466,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -496,10 +489,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -507,18 +500,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -541,8 +535,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -576,8 +570,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -609,8 +603,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -648,10 +642,11 @@ async def begin_update( 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("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -676,10 +671,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -691,7 +686,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -703,10 +698,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -714,6 +709,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -722,8 +721,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -733,8 +736,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -754,7 +757,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -765,6 +768,7 @@ async def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py index 169e0eca6ed8..329567f25972 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._afd_profiles_operations import ( build_check_endpoint_name_availability_request, build_check_host_name_availability_request, @@ -39,12 +40,8 @@ build_upgrade_request, build_validate_secret_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +60,10 @@ class AFDProfilesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def check_endpoint_name_availability( @@ -149,7 +146,7 @@ async def check_endpoint_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,7 +180,6 @@ async def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -198,7 +194,7 @@ async def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -213,8 +209,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] @@ -226,7 +222,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,7 +241,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -261,7 +256,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -306,8 +300,8 @@ async def check_host_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Required. :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput @@ -334,8 +328,8 @@ async def check_host_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Required. :type check_host_name_availability_input: IO[bytes] @@ -360,8 +354,8 @@ async def check_host_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Is either a CheckHostNameAvailabilityInput type or a IO[bytes] type. Required. @@ -371,7 +365,7 @@ async def check_host_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,7 +399,6 @@ async def check_host_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -420,7 +413,7 @@ async def check_host_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -503,7 +496,7 @@ async def validate_secret( :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -537,7 +530,6 @@ async def validate_secret( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -552,7 +544,7 @@ async def validate_secret( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) + deserialized = self._deserialize("ValidateSecretOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -565,8 +557,8 @@ async def _upgrade_initial( profile_name: str, profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -579,7 +571,7 @@ async def _upgrade_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -600,10 +592,10 @@ async def _upgrade_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -611,18 +603,19 @@ async def _upgrade_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -729,10 +722,11 @@ async def begin_upgrade( 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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py index adef934cf76f..f20c85812d27 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,31 +20,26 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +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 ..._vendor import _convert_request +from ..._utils.utils import ClientMixinABC from ...operations._cdn_management_client_operations import ( build_check_endpoint_name_availability_request, build_check_name_availability_request, build_check_name_availability_with_subscription_request, build_validate_probe_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CdnManagementClientOperationsMixin(CdnManagementClientMixinABC): +class CdnManagementClientOperationsMixin(ClientMixinABC[AsyncPipelineClient, CdnManagementClientConfiguration]): @overload async def check_endpoint_name_availability( @@ -114,7 +110,7 @@ async def check_endpoint_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -147,7 +143,6 @@ async def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -162,7 +157,7 @@ async def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -222,7 +217,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,7 +248,6 @@ async def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -268,7 +262,7 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -328,7 +322,7 @@ async def check_name_availability_with_subscription( # pylint: disable=name-too :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +354,6 @@ async def check_name_availability_with_subscription( # pylint: disable=name-too headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -375,7 +368,7 @@ async def check_name_availability_with_subscription( # pylint: disable=name-too error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -433,7 +426,7 @@ async def validate_probe( :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,7 +458,6 @@ async def validate_probe( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -480,7 +472,7 @@ async def validate_probe( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) + deserialized = self._deserialize("ValidateProbeOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py index 52a4b04d3882..d252441c1d3e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._custom_domains_operations import ( build_create_request, build_delete_request, @@ -40,12 +41,8 @@ build_get_request, build_list_by_endpoint_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,10 +61,10 @@ class CustomDomainsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -93,7 +90,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomainListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -113,7 +110,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -129,7 +125,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -179,7 +174,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.CustomDomain :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,7 +198,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,7 +212,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -233,8 +227,8 @@ async def _create_initial( custom_domain_name: str, custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,7 +241,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -270,10 +264,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -281,21 +275,19 @@ async def _create_initial( 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 == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -425,10 +417,11 @@ async def begin_create( 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("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -452,8 +445,8 @@ def get_long_running_output(pipeline_response): async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> Optional[_models.CustomDomain]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,7 +458,7 @@ async def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.CustomDomain]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -477,10 +470,10 @@ async def _delete_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -488,16 +481,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -545,6 +541,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -552,7 +549,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -576,8 +573,8 @@ def get_long_running_output(pipeline_response): async def _disable_custom_https_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,7 +586,7 @@ async def _disable_custom_https_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_disable_custom_https_request( resource_group_name=resource_group_name, @@ -601,10 +598,10 @@ async def _disable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -612,18 +609,19 @@ async def _disable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -671,10 +669,11 @@ async def begin_disable_custom_https( 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("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -704,8 +703,8 @@ async def _enable_custom_https_initial( custom_domain_name: str, custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -718,7 +717,7 @@ async def _enable_custom_https_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -744,10 +743,10 @@ async def _enable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -755,18 +754,19 @@ async def _enable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -903,10 +903,11 @@ async def begin_enable_custom_https( 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("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py index 4cb0f22ba810..f70486d72fbc 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,21 +20,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +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 ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._edge_nodes_operations import build_list_request -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,10 +48,10 @@ class EdgeNodesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> AsyncIterable["_models.EdgeNode"]: @@ -73,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.EdgeNode"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EdgenodeResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,7 +84,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -105,7 +99,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py index 3e51c9b51c27..72ef6f9cff5a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +6,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +19,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +33,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._endpoints_operations import ( build_create_request, build_delete_request, @@ -45,12 +47,8 @@ build_update_request, build_validate_custom_domain_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,10 +67,10 @@ class EndpointsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -95,7 +93,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -114,7 +112,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -130,7 +127,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -179,7 +175,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.Endpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -202,7 +198,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,7 +212,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -231,8 +226,8 @@ async def _create_initial( endpoint_name: str, endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,7 +240,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -267,10 +262,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -278,21 +273,19 @@ async def _create_initial( 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -414,10 +407,11 @@ async def begin_create( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -446,8 +440,8 @@ async def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -460,7 +454,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -482,10 +476,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -493,18 +487,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -633,10 +628,11 @@ async def begin_update( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -658,10 +654,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -673,7 +669,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -684,10 +680,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -695,6 +691,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -703,8 +703,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -734,7 +738,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -744,6 +748,7 @@ async def begin_delete( 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 @@ -767,8 +772,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- async def _start_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -780,7 +785,7 @@ async def _start_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_start_request( resource_group_name=resource_group_name, @@ -791,10 +796,10 @@ async def _start_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -802,18 +807,19 @@ async def _start_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -858,10 +864,11 @@ async def begin_start( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -885,8 +892,8 @@ def get_long_running_output(pipeline_response): async def _stop_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -898,7 +905,7 @@ async def _stop_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_stop_request( resource_group_name=resource_group_name, @@ -909,10 +916,10 @@ async def _stop_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -920,18 +927,19 @@ async def _stop_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -976,10 +984,11 @@ async def begin_stop( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1001,15 +1010,15 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _purge_content_initial( # pylint: disable=inconsistent-return-statements + async def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1022,7 +1031,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1044,10 +1053,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1055,6 +1064,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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) @@ -1063,8 +1076,12 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_purge_content( @@ -1170,7 +1187,7 @@ async def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._purge_content_initial( # type: ignore + raw_result = await self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1182,6 +1199,7 @@ async def begin_purge_content( 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 @@ -1203,15 +1221,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _load_content_initial( # pylint: disable=inconsistent-return-statements + async def _load_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1224,7 +1242,7 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1246,10 +1264,10 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1257,6 +1275,10 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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) @@ -1265,8 +1287,12 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_load_content( @@ -1369,7 +1395,7 @@ async def begin_load_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._load_content_initial( # type: ignore + raw_result = await self._load_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1381,6 +1407,7 @@ async def begin_load_content( 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 @@ -1490,7 +1517,7 @@ async def validate_custom_domain( :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1525,7 +1552,6 @@ async def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1540,7 +1566,7 @@ async def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1571,7 +1597,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1591,7 +1617,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1607,7 +1632,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py index a76b3c5219f4..44647a4fc91c 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by 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 -import sys -from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +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 ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._log_analytics_operations import ( build_get_log_analytics_locations_request, build_get_log_analytics_metrics_request, @@ -35,12 +34,8 @@ build_get_waf_log_analytics_metrics_request, build_get_waf_log_analytics_rankings_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,10 +54,10 @@ class LogAnalyticsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(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_log_analytics_metrics( @@ -109,7 +104,7 @@ async def get_log_analytics_metrics( :rtype: ~azure.mgmt.cdn.models.MetricsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,7 +135,6 @@ async def get_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,7 +149,7 @@ async def get_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MetricsResponse", pipeline_response) + deserialized = self._deserialize("MetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -198,7 +192,7 @@ async def get_log_analytics_rankings( :rtype: ~azure.mgmt.cdn.models.RankingsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,7 +220,6 @@ async def get_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -241,7 +234,7 @@ async def get_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RankingsResponse", pipeline_response) + deserialized = self._deserialize("RankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -263,7 +256,7 @@ async def get_log_analytics_locations( :rtype: ~azure.mgmt.cdn.models.ContinentsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -285,7 +278,6 @@ async def get_log_analytics_locations( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -300,7 +292,7 @@ async def get_log_analytics_locations( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContinentsResponse", pipeline_response) + deserialized = self._deserialize("ContinentsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -322,7 +314,7 @@ async def get_log_analytics_resources( :rtype: ~azure.mgmt.cdn.models.ResourcesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,7 +336,6 @@ async def get_log_analytics_resources( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -359,7 +350,7 @@ async def get_log_analytics_resources( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourcesResponse", pipeline_response) + deserialized = self._deserialize("ResourcesResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -405,7 +396,7 @@ async def get_waf_log_analytics_metrics( :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,7 +425,6 @@ async def get_waf_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -449,7 +439,7 @@ async def get_waf_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafMetricsResponse", pipeline_response) + deserialized = self._deserialize("WafMetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -495,7 +485,7 @@ async def get_waf_log_analytics_rankings( :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,7 +514,6 @@ async def get_waf_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -539,7 +528,7 @@ async def get_waf_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafRankingsResponse", pipeline_response) + deserialized = self._deserialize("WafRankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py index 2e8eb598ea06..6324235779c7 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,21 +20,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +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 ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._managed_rule_sets_operations import build_list_request -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,10 +48,10 @@ class ManagedRuleSetsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> AsyncIterable["_models.ManagedRuleSetDefinition"]: @@ -74,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedRuleSetDefinitionList] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,7 +86,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -107,7 +101,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py index cf1ad39ae373..b75158c5f480 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,21 +20,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +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 ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import build_list_request -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,10 +48,10 @@ class Operations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> AsyncIterable["_models.Operation"]: @@ -72,7 +67,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,7 +83,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -104,7 +98,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py index 3512194ddb18..adf9ed0b1a3d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._origin_groups_operations import ( build_create_request, build_delete_request, @@ -39,12 +40,8 @@ build_list_by_endpoint_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +60,10 @@ class OriginGroupsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -92,7 +89,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OriginGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,7 +109,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +124,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -179,7 +174,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.OriginGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,7 +198,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,7 +212,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -233,8 +227,8 @@ async def _create_initial( origin_group_name: str, origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,7 +241,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -270,10 +264,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -281,21 +275,19 @@ async def _create_initial( 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 == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -428,10 +420,11 @@ async def begin_create( 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("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -461,8 +454,8 @@ async def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -475,7 +468,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -498,10 +491,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -509,18 +502,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -654,10 +648,11 @@ async def begin_update( 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("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -679,10 +674,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -694,7 +689,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -706,10 +701,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -717,6 +712,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -725,8 +724,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -758,7 +761,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -769,6 +772,7 @@ async def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py index 21192a6e9ad0..f4c0f5e21b30 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._origins_operations import ( build_create_request, build_delete_request, @@ -39,12 +40,8 @@ build_list_by_endpoint_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +60,10 @@ class OriginsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -92,7 +89,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OriginListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,7 +109,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +124,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -178,7 +173,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.Origin :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -202,7 +197,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,7 +211,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -232,8 +226,8 @@ async def _create_initial( origin_name: str, origin: Union[_models.Origin, IO[bytes]], **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,7 +240,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -269,10 +263,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -280,21 +274,19 @@ async def _create_initial( 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 == 200: - deserialized = self._deserialize("Origin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -423,10 +415,11 @@ async def begin_create( 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("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -456,8 +449,8 @@ async def _update_initial( origin_name: str, origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,7 +463,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -493,10 +486,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -504,18 +497,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -645,10 +639,11 @@ async def begin_update( 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("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -670,10 +665,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -685,7 +680,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -697,10 +692,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -708,6 +703,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -716,8 +715,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -748,7 +751,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -759,6 +762,7 @@ async def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py index 7e6760ff2bf3..baff8f130bdd 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +6,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +19,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +33,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policies_operations import ( build_create_or_update_request, build_delete_request, @@ -39,12 +41,8 @@ build_list_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +61,10 @@ class PoliciesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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, **kwargs: Any) -> AsyncIterable["_models.CdnWebApplicationFirewallPolicy"]: @@ -86,7 +84,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CdnWebApplicationFirewallPolicyList] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,7 +102,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -120,7 +117,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,7 +160,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,7 +182,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -201,7 +196,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -214,8 +209,8 @@ async def _create_or_update_initial( policy_name: str, cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +223,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -249,10 +244,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -260,21 +255,19 @@ async def _create_or_update_initial( 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 == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -383,10 +376,11 @@ async def begin_create_or_update( 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("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -416,8 +410,8 @@ async def _update_initial( _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -430,7 +424,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -453,10 +447,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -464,18 +458,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -592,10 +587,11 @@ async def begin_update( 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("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -618,9 +614,7 @@ def get_long_running_output(pipeline_response): ) @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, policy_name: str, **kwargs: Any - ) -> None: + async def delete(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> None: """Deletes Policy. :param resource_group_name: Name of the Resource group within the Azure subscription. Required. @@ -631,7 +625,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -653,7 +647,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py index 83eebbe330db..bd790427494e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +6,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +19,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,9 +33,11 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._profiles_operations import ( build_can_migrate_request, + build_cdn_can_migrate_to_afd_request, + build_cdn_migrate_to_afd_request, build_create_request, build_delete_request, build_generate_sso_uri_request, @@ -43,20 +47,17 @@ build_list_resource_usage_request, build_list_supported_optimization_types_request, build_migrate_request, + build_migration_abort_request, build_migration_commit_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ProfilesOperations: +class ProfilesOperations: # pylint: disable=too-many-public-methods """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,10 +71,10 @@ class ProfilesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> AsyncIterable["_models.Profile"]: @@ -90,7 +91,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProfileListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,7 +108,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -123,7 +123,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -170,7 +169,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProfileListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,7 +187,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -204,7 +202,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -248,7 +245,7 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) :rtype: ~azure.mgmt.cdn.models.Profile :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,7 +267,6 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -285,7 +281,7 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -294,8 +290,8 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) async def _create_initial( self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,7 +304,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -329,10 +325,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -340,21 +336,19 @@ async def _create_initial( 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 == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -460,10 +454,11 @@ async def begin_create( 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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -491,8 +486,8 @@ async def _update_initial( profile_name: str, profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -505,7 +500,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -526,10 +521,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -537,18 +532,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -660,10 +656,11 @@ async def begin_update( 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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -685,10 +682,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + async def _delete_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -700,7 +695,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -710,10 +705,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -721,6 +716,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -729,8 +728,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + 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, profile_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -756,7 +759,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -765,6 +768,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar 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 @@ -791,8 +795,8 @@ async def _can_migrate_initial( resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CanMigrateResult]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -805,7 +809,7 @@ async def _can_migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CanMigrateResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -825,10 +829,10 @@ async def _can_migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -836,18 +840,20 @@ async def _can_migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CanMigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -942,10 +948,11 @@ async def begin_can_migrate( 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("CanMigrateResult", pipeline_response) + deserialized = self._deserialize("CanMigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -974,8 +981,8 @@ async def _migrate_initial( resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO[bytes]], **kwargs: Any - ) -> _models.MigrateResult: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,7 +995,7 @@ async def _migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MigrateResult] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1008,10 +1015,10 @@ async def _migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1019,18 +1026,19 @@ async def _migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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 == 200: - deserialized = self._deserialize("MigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("MigrateResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1127,10 +1135,11 @@ async def begin_migrate( 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("MigrateResult", pipeline_response) + deserialized = self._deserialize("MigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1154,10 +1163,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migration_commit_initial( # pylint: disable=inconsistent-return-statements + async def _migration_commit_initial( self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1169,7 +1178,7 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_migration_commit_request( resource_group_name=resource_group_name, @@ -1179,10 +1188,10 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1190,6 +1199,10 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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) @@ -1198,8 +1211,12 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_migration_commit( @@ -1225,7 +1242,7 @@ async def begin_migration_commit( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._migration_commit_initial( # type: ignore + raw_result = await self._migration_commit_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -1234,6 +1251,7 @@ async def begin_migration_commit( 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 @@ -1275,7 +1293,7 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** :rtype: ~azure.mgmt.cdn.models.SsoUri :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1297,7 +1315,6 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1312,7 +1329,7 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SsoUri", pipeline_response) + deserialized = self._deserialize("SsoUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1335,7 +1352,7 @@ async def list_supported_optimization_types( :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1357,7 +1374,6 @@ async def list_supported_optimization_types( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1372,7 +1388,7 @@ async def list_supported_optimization_types( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) + deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1401,7 +1417,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1420,7 +1436,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1436,7 +1451,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1465,3 +1479,438 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) + + async def _cdn_can_migrate_to_afd_initial( + self, resource_group_name: str, profile_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_cdn_can_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_cdn_can_migrate_to_afd( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.CanMigrateResult]: + """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :return: An instance of AsyncLROPoller that returns either CanMigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CanMigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cdn_can_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_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("CanMigrateResult", 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.CanMigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CanMigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _cdn_migrate_to_afd_initial( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, 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(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _json = self._serialize.body(migration_parameters, "CdnMigrationToAfdParameters") + + _request = build_cdn_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: _models.CdnMigrationToAfdParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters + :keyword content_type: Body Parameter 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 MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: IO[bytes] + :keyword content_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 MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Is either a + CdnMigrationToAfdParameters type or a IO[bytes] type. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_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.MigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cdn_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + migration_parameters=migration_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("MigrateResult", 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.MigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.MigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _migration_abort_initial( + self, resource_group_name: str, profile_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_migration_abort_request( + resource_group_name=resource_group_name, + profile_name=profile_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]: + try: + await response.read() # Load the body 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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_migration_abort( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Abort the migration to Azure Frontdoor Premium/Standard. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_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._migration_abort_initial( + resource_group_name=resource_group_name, + profile_name=profile_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/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py index 1c15d9080763..f0b1afcb4a1b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,21 +20,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +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 ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._resource_usage_operations import build_list_request -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,10 +48,10 @@ class ResourceUsageOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> AsyncIterable["_models.ResourceUsage"]: @@ -72,7 +67,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceUsage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,7 +84,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -105,7 +99,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py index f75e5288b804..52ce0c13e9e3 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._routes_operations import ( build_create_request, build_delete_request, @@ -39,12 +40,8 @@ build_list_by_endpoint_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +60,10 @@ class RoutesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -76,8 +73,8 @@ def list_by_endpoint( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -92,7 +89,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RouteListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,7 +109,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +124,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -167,8 +162,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -179,7 +174,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.Route :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,7 +198,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,7 +212,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -233,8 +227,8 @@ async def _create_initial( route_name: str, route: Union[_models.Route, IO[bytes]], **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,7 +241,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -270,10 +264,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -281,21 +275,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -319,8 +311,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -354,8 +346,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -387,8 +379,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -424,10 +416,11 @@ async def begin_create( 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("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -460,8 +453,8 @@ async def _update_initial( route_name: str, route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,7 +467,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -497,10 +490,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -508,18 +501,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -543,8 +537,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -578,8 +572,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -611,8 +605,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -649,10 +643,11 @@ async def begin_update( 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("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -677,10 +672,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -692,7 +687,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -704,10 +699,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -715,6 +710,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -723,8 +722,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -735,8 +738,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -756,7 +759,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -767,6 +770,7 @@ async def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py index fc4b3e11a657..4d1f80f1aaf4 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union, cast +from collections.abc import MutableMapping +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -30,7 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._rule_sets_operations import ( build_create_request, build_delete_request, @@ -38,12 +39,8 @@ build_list_by_profile_request, build_list_resource_usage_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -62,10 +59,10 @@ class RuleSetsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -75,8 +72,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either RuleSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.RuleSet] @@ -88,7 +85,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleSetListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,7 +104,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -123,7 +119,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -162,8 +157,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -172,7 +167,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,7 +190,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -210,7 +204,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -225,8 +219,8 @@ async def create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -235,7 +229,7 @@ async def create( :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,7 +252,6 @@ async def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -273,21 +266,17 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RuleSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,7 +288,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -310,10 +299,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -321,6 +310,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -329,8 +322,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -341,8 +338,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -360,7 +357,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -370,6 +367,7 @@ async def begin_delete( 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 @@ -402,8 +400,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -418,7 +416,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,7 +436,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -454,7 +451,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py index 3461ad98d882..6fe304757c34 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._rules_operations import ( build_create_request, build_delete_request, @@ -39,12 +40,8 @@ build_list_by_rule_set_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +60,10 @@ class RulesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_rule_set( @@ -76,8 +73,8 @@ def list_by_rule_set( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -91,7 +88,7 @@ def list_by_rule_set( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,7 +108,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -127,7 +123,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -165,8 +160,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -176,7 +171,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.Rule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,7 +195,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -215,7 +209,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -230,8 +224,8 @@ async def _create_initial( rule_name: str, rule: Union[_models.Rule, IO[bytes]], **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +238,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -267,10 +261,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -278,21 +272,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -315,8 +307,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -348,8 +340,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -379,8 +371,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -415,10 +407,11 @@ async def begin_create( 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("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -451,8 +444,8 @@ async def _update_initial( rule_name: str, rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,7 +458,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -488,10 +481,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -499,18 +492,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -533,8 +527,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -566,8 +560,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -597,8 +591,8 @@ async def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -634,10 +628,11 @@ async def begin_update( 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("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -662,10 +657,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,7 +672,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -689,10 +684,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -700,6 +695,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -708,8 +707,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -719,8 +722,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -739,7 +742,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -750,6 +753,7 @@ async def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py index 181fb64700c9..b993d1d7edb3 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,19 +32,15 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._secrets_operations import ( build_create_request, build_delete_request, build_get_request, build_list_by_profile_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -62,10 +59,10 @@ class SecretsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -75,8 +72,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either Secret or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Secret] @@ -88,7 +85,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,7 +104,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -123,7 +119,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -159,8 +154,8 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -168,7 +163,7 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st :rtype: ~azure.mgmt.cdn.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,7 +186,6 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -206,7 +200,7 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -220,8 +214,8 @@ async def _create_initial( secret_name: str, secret: Union[_models.Secret, IO[bytes]], **kwargs: Any - ) -> _models.Secret: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,7 +228,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -256,10 +250,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -267,21 +261,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -303,8 +295,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -334,8 +326,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -363,8 +355,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -397,10 +389,11 @@ async def begin_create( 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("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -425,10 +418,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,7 +433,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -451,10 +444,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -462,6 +455,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -470,8 +467,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -481,8 +482,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -499,7 +500,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_name, @@ -509,6 +510,7 @@ async def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py index 5a81547b0bc7..80b420e4565a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (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 sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, 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, @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.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 @@ -31,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._security_policies_operations import ( build_create_request, build_delete_request, @@ -39,12 +40,8 @@ build_list_by_profile_request, build_patch_request, ) -from .._vendor import CdnManagementClientMixinABC +from .._configuration import CdnManagementClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,10 +60,10 @@ class SecurityPoliciesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -76,8 +73,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.SecurityPolicy] @@ -89,7 +86,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecurityPolicyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,7 +105,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -124,7 +120,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -162,8 +157,8 @@ async def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -171,7 +166,7 @@ async def get( :rtype: ~azure.mgmt.cdn.models.SecurityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,7 +189,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -209,7 +203,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -223,8 +217,8 @@ async def _create_initial( security_policy_name: str, security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -237,7 +231,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -259,10 +253,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -270,21 +264,19 @@ async def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -306,8 +298,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -337,8 +329,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -366,8 +358,8 @@ async def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -401,10 +393,11 @@ async def begin_create( 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("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -436,8 +429,8 @@ async def _patch_initial( security_policy_name: str, security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +443,7 @@ async def _patch_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -472,10 +465,10 @@ async def _patch_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -483,18 +476,19 @@ async def _patch_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -516,8 +510,8 @@ async def begin_patch( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -547,8 +541,8 @@ async def begin_patch( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -576,8 +570,8 @@ async def begin_patch( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -612,10 +606,11 @@ async def begin_patch( 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("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -640,10 +635,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -655,7 +650,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -666,10 +661,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -677,6 +672,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -685,8 +684,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -696,8 +699,8 @@ async def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -714,7 +717,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -724,6 +727,7 @@ async def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py index c82bb7b540c6..5363b321ac12 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py @@ -5,413 +5,409 @@ # 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 -from ._models_py3 import AFDDomain -from ._models_py3 import AFDDomainHttpsParameters -from ._models_py3 import AFDDomainListResult -from ._models_py3 import AFDDomainProperties -from ._models_py3 import AFDDomainUpdateParameters -from ._models_py3 import AFDDomainUpdatePropertiesParameters -from ._models_py3 import AFDEndpoint -from ._models_py3 import AFDEndpointListResult -from ._models_py3 import AFDEndpointProperties -from ._models_py3 import AFDEndpointPropertiesUpdateParameters -from ._models_py3 import AFDEndpointUpdateParameters -from ._models_py3 import AFDOrigin -from ._models_py3 import AFDOriginGroup -from ._models_py3 import AFDOriginGroupListResult -from ._models_py3 import AFDOriginGroupProperties -from ._models_py3 import AFDOriginGroupUpdateParameters -from ._models_py3 import AFDOriginGroupUpdatePropertiesParameters -from ._models_py3 import AFDOriginListResult -from ._models_py3 import AFDOriginProperties -from ._models_py3 import AFDOriginUpdateParameters -from ._models_py3 import AFDOriginUpdatePropertiesParameters -from ._models_py3 import AFDStateProperties -from ._models_py3 import ActivatedResourceReference -from ._models_py3 import AfdErrorResponse -from ._models_py3 import AfdPurgeParameters -from ._models_py3 import AfdRouteCacheConfiguration -from ._models_py3 import AzureFirstPartyManagedCertificate -from ._models_py3 import AzureFirstPartyManagedCertificateParameters -from ._models_py3 import CacheConfiguration -from ._models_py3 import CacheExpirationActionParameters -from ._models_py3 import CacheKeyQueryStringActionParameters -from ._models_py3 import CanMigrateParameters -from ._models_py3 import CanMigrateResult -from ._models_py3 import CdnCertificateSourceParameters -from ._models_py3 import CdnEndpoint -from ._models_py3 import CdnManagedHttpsParameters -from ._models_py3 import CdnWebApplicationFirewallPolicy -from ._models_py3 import CdnWebApplicationFirewallPolicyList -from ._models_py3 import CdnWebApplicationFirewallPolicyPatchParameters -from ._models_py3 import Certificate -from ._models_py3 import CheckEndpointNameAvailabilityInput -from ._models_py3 import CheckEndpointNameAvailabilityOutput -from ._models_py3 import CheckHostNameAvailabilityInput -from ._models_py3 import CheckNameAvailabilityInput -from ._models_py3 import CheckNameAvailabilityOutput -from ._models_py3 import CidrIpAddress -from ._models_py3 import ClientPortMatchConditionParameters -from ._models_py3 import Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems -from ._models_py3 import Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems -from ._models_py3 import ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems -from ._models_py3 import CompressionSettings -from ._models_py3 import ContinentsResponse -from ._models_py3 import ContinentsResponseContinentsItem -from ._models_py3 import ContinentsResponseCountryOrRegionsItem -from ._models_py3 import CookiesMatchConditionParameters -from ._models_py3 import CustomDomain -from ._models_py3 import CustomDomainHttpsParameters -from ._models_py3 import CustomDomainListResult -from ._models_py3 import CustomDomainParameters -from ._models_py3 import CustomRule -from ._models_py3 import CustomRuleList -from ._models_py3 import CustomerCertificate -from ._models_py3 import CustomerCertificateParameters -from ._models_py3 import DeepCreatedCustomDomain -from ._models_py3 import DeepCreatedOrigin -from ._models_py3 import DeepCreatedOriginGroup -from ._models_py3 import DeliveryRule -from ._models_py3 import DeliveryRuleAction -from ._models_py3 import DeliveryRuleCacheExpirationAction -from ._models_py3 import DeliveryRuleCacheKeyQueryStringAction -from ._models_py3 import DeliveryRuleClientPortCondition -from ._models_py3 import DeliveryRuleCondition -from ._models_py3 import DeliveryRuleCookiesCondition -from ._models_py3 import DeliveryRuleHostNameCondition -from ._models_py3 import DeliveryRuleHttpVersionCondition -from ._models_py3 import DeliveryRuleIsDeviceCondition -from ._models_py3 import DeliveryRulePostArgsCondition -from ._models_py3 import DeliveryRuleQueryStringCondition -from ._models_py3 import DeliveryRuleRemoteAddressCondition -from ._models_py3 import DeliveryRuleRequestBodyCondition -from ._models_py3 import DeliveryRuleRequestHeaderAction -from ._models_py3 import DeliveryRuleRequestHeaderCondition -from ._models_py3 import DeliveryRuleRequestMethodCondition -from ._models_py3 import DeliveryRuleRequestSchemeCondition -from ._models_py3 import DeliveryRuleRequestUriCondition -from ._models_py3 import DeliveryRuleResponseHeaderAction -from ._models_py3 import DeliveryRuleRouteConfigurationOverrideAction -from ._models_py3 import DeliveryRuleServerPortCondition -from ._models_py3 import DeliveryRuleSocketAddrCondition -from ._models_py3 import DeliveryRuleSslProtocolCondition -from ._models_py3 import DeliveryRuleUrlFileExtensionCondition -from ._models_py3 import DeliveryRuleUrlFileNameCondition -from ._models_py3 import DeliveryRuleUrlPathCondition -from ._models_py3 import DimensionProperties -from ._models_py3 import DomainValidationProperties -from ._models_py3 import EdgeNode -from ._models_py3 import EdgenodeResult -from ._models_py3 import Endpoint -from ._models_py3 import EndpointListResult -from ._models_py3 import EndpointProperties -from ._models_py3 import EndpointPropertiesUpdateParameters -from ._models_py3 import EndpointPropertiesUpdateParametersDeliveryPolicy -from ._models_py3 import EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink -from ._models_py3 import EndpointUpdateParameters -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import GeoFilter -from ._models_py3 import HeaderActionParameters -from ._models_py3 import HealthProbeParameters -from ._models_py3 import HostNameMatchConditionParameters -from ._models_py3 import HttpErrorRangeParameters -from ._models_py3 import HttpVersionMatchConditionParameters -from ._models_py3 import IpAddressGroup -from ._models_py3 import IsDeviceMatchConditionParameters -from ._models_py3 import KeyVaultCertificateSourceParameters -from ._models_py3 import KeyVaultSigningKeyParameters -from ._models_py3 import LoadBalancingSettingsParameters -from ._models_py3 import LoadParameters -from ._models_py3 import LogSpecification -from ._models_py3 import ManagedCertificate -from ._models_py3 import ManagedCertificateParameters -from ._models_py3 import ManagedRuleDefinition -from ._models_py3 import ManagedRuleGroupDefinition -from ._models_py3 import ManagedRuleGroupOverride -from ._models_py3 import ManagedRuleOverride -from ._models_py3 import ManagedRuleSet -from ._models_py3 import ManagedRuleSetDefinition -from ._models_py3 import ManagedRuleSetDefinitionList -from ._models_py3 import ManagedRuleSetList -from ._models_py3 import ManagedServiceIdentity -from ._models_py3 import MatchCondition -from ._models_py3 import MetricAvailability -from ._models_py3 import MetricSpecification -from ._models_py3 import MetricsResponse -from ._models_py3 import MetricsResponseSeriesItem -from ._models_py3 import MetricsResponseSeriesPropertiesItemsItem -from ._models_py3 import MigrateResult -from ._models_py3 import MigrationErrorType -from ._models_py3 import MigrationParameters -from ._models_py3 import MigrationWebApplicationFirewallMapping -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationsListResult -from ._models_py3 import Origin -from ._models_py3 import OriginGroup -from ._models_py3 import OriginGroupListResult -from ._models_py3 import OriginGroupOverride -from ._models_py3 import OriginGroupOverrideAction -from ._models_py3 import OriginGroupOverrideActionParameters -from ._models_py3 import OriginGroupProperties -from ._models_py3 import OriginGroupUpdateParameters -from ._models_py3 import OriginGroupUpdatePropertiesParameters -from ._models_py3 import OriginListResult -from ._models_py3 import OriginProperties -from ._models_py3 import OriginUpdateParameters -from ._models_py3 import OriginUpdatePropertiesParameters -from ._models_py3 import PolicySettings -from ._models_py3 import PostArgsMatchConditionParameters -from ._models_py3 import Profile -from ._models_py3 import ProfileChangeSkuWafMapping -from ._models_py3 import ProfileListResult -from ._models_py3 import ProfileLogScrubbing -from ._models_py3 import ProfileScrubbingRules -from ._models_py3 import ProfileUpdateParameters -from ._models_py3 import ProfileUpgradeParameters -from ._models_py3 import ProxyResource -from ._models_py3 import PurgeParameters -from ._models_py3 import QueryStringMatchConditionParameters -from ._models_py3 import RankingsResponse -from ._models_py3 import RankingsResponseTablesItem -from ._models_py3 import RankingsResponseTablesPropertiesItemsItem -from ._models_py3 import RankingsResponseTablesPropertiesItemsMetricsItem -from ._models_py3 import RateLimitRule -from ._models_py3 import RateLimitRuleList -from ._models_py3 import RemoteAddressMatchConditionParameters -from ._models_py3 import RequestBodyMatchConditionParameters -from ._models_py3 import RequestHeaderMatchConditionParameters -from ._models_py3 import RequestMethodMatchConditionParameters -from ._models_py3 import RequestSchemeMatchConditionParameters -from ._models_py3 import RequestUriMatchConditionParameters -from ._models_py3 import Resource -from ._models_py3 import ResourceReference -from ._models_py3 import ResourceUsage -from ._models_py3 import ResourceUsageListResult -from ._models_py3 import ResourcesResponse -from ._models_py3 import ResourcesResponseCustomDomainsItem -from ._models_py3 import ResourcesResponseEndpointsItem -from ._models_py3 import ResourcesResponseEndpointsPropertiesItemsItem -from ._models_py3 import ResponseBasedOriginErrorDetectionParameters -from ._models_py3 import Route -from ._models_py3 import RouteConfigurationOverrideActionParameters -from ._models_py3 import RouteListResult -from ._models_py3 import RouteProperties -from ._models_py3 import RouteUpdateParameters -from ._models_py3 import RouteUpdatePropertiesParameters -from ._models_py3 import Rule -from ._models_py3 import RuleListResult -from ._models_py3 import RuleProperties -from ._models_py3 import RuleSet -from ._models_py3 import RuleSetListResult -from ._models_py3 import RuleSetProperties -from ._models_py3 import RuleUpdateParameters -from ._models_py3 import RuleUpdatePropertiesParameters -from ._models_py3 import Secret -from ._models_py3 import SecretListResult -from ._models_py3 import SecretParameters -from ._models_py3 import SecretProperties -from ._models_py3 import SecurityPolicy -from ._models_py3 import SecurityPolicyListResult -from ._models_py3 import SecurityPolicyProperties -from ._models_py3 import SecurityPolicyPropertiesParameters -from ._models_py3 import SecurityPolicyUpdateParameters -from ._models_py3 import SecurityPolicyWebApplicationFirewallAssociation -from ._models_py3 import SecurityPolicyWebApplicationFirewallParameters -from ._models_py3 import ServerPortMatchConditionParameters -from ._models_py3 import ServiceSpecification -from ._models_py3 import SharedPrivateLinkResourceProperties -from ._models_py3 import Sku -from ._models_py3 import SocketAddrMatchConditionParameters -from ._models_py3 import SslProtocolMatchConditionParameters -from ._models_py3 import SsoUri -from ._models_py3 import SupportedOptimizationTypesListResult -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource -from ._models_py3 import UrlFileExtensionMatchConditionParameters -from ._models_py3 import UrlFileNameMatchConditionParameters -from ._models_py3 import UrlPathMatchConditionParameters -from ._models_py3 import UrlRedirectAction -from ._models_py3 import UrlRedirectActionParameters -from ._models_py3 import UrlRewriteAction -from ._models_py3 import UrlRewriteActionParameters -from ._models_py3 import UrlSigningAction -from ._models_py3 import UrlSigningActionParameters -from ._models_py3 import UrlSigningKey -from ._models_py3 import UrlSigningKeyParameters -from ._models_py3 import UrlSigningParamIdentifier -from ._models_py3 import Usage -from ._models_py3 import UsageName -from ._models_py3 import UsagesListResult -from ._models_py3 import UserAssignedIdentity -from ._models_py3 import UserManagedHttpsParameters -from ._models_py3 import ValidateCustomDomainInput -from ._models_py3 import ValidateCustomDomainOutput -from ._models_py3 import ValidateProbeInput -from ._models_py3 import ValidateProbeOutput -from ._models_py3 import ValidateSecretInput -from ._models_py3 import ValidateSecretOutput -from ._models_py3 import ValidationToken -from ._models_py3 import WafMetricsResponse -from ._models_py3 import WafMetricsResponseSeriesItem -from ._models_py3 import WafMetricsResponseSeriesPropertiesItemsItem -from ._models_py3 import WafRankingsResponse -from ._models_py3 import WafRankingsResponseDataItem +from typing import TYPE_CHECKING -from ._cdn_management_client_enums import AFDEndpointProtocols -from ._cdn_management_client_enums import ActionType -from ._cdn_management_client_enums import AfdCertificateType -from ._cdn_management_client_enums import AfdMinimumTlsVersion -from ._cdn_management_client_enums import AfdProvisioningState -from ._cdn_management_client_enums import AfdQueryStringCachingBehavior -from ._cdn_management_client_enums import Algorithm -from ._cdn_management_client_enums import AutoGeneratedDomainNameLabelScope -from ._cdn_management_client_enums import CacheBehavior -from ._cdn_management_client_enums import CacheExpirationActionParametersTypeName -from ._cdn_management_client_enums import CacheKeyQueryStringActionParametersTypeName -from ._cdn_management_client_enums import CacheType -from ._cdn_management_client_enums import CanMigrateDefaultSku -from ._cdn_management_client_enums import CdnCertificateSourceParametersTypeName -from ._cdn_management_client_enums import CertificateSource -from ._cdn_management_client_enums import CertificateType -from ._cdn_management_client_enums import ClientPortMatchConditionParametersTypeName -from ._cdn_management_client_enums import ClientPortOperator -from ._cdn_management_client_enums import CookiesMatchConditionParametersTypeName -from ._cdn_management_client_enums import CookiesOperator -from ._cdn_management_client_enums import CustomDomainResourceState -from ._cdn_management_client_enums import CustomHttpsProvisioningState -from ._cdn_management_client_enums import CustomHttpsProvisioningSubstate -from ._cdn_management_client_enums import CustomRuleEnabledState -from ._cdn_management_client_enums import DeleteRule -from ._cdn_management_client_enums import DeliveryRuleActionEnum -from ._cdn_management_client_enums import DeploymentStatus -from ._cdn_management_client_enums import DestinationProtocol -from ._cdn_management_client_enums import DomainValidationState -from ._cdn_management_client_enums import EnabledState -from ._cdn_management_client_enums import EndpointProvisioningState -from ._cdn_management_client_enums import EndpointResourceState -from ._cdn_management_client_enums import ForwardingProtocol -from ._cdn_management_client_enums import GeoFilterActions -from ._cdn_management_client_enums import HeaderAction -from ._cdn_management_client_enums import HeaderActionParametersTypeName -from ._cdn_management_client_enums import HealthProbeRequestType -from ._cdn_management_client_enums import HostNameMatchConditionParametersTypeName -from ._cdn_management_client_enums import HostNameOperator -from ._cdn_management_client_enums import HttpVersionMatchConditionParametersTypeName -from ._cdn_management_client_enums import HttpVersionOperator -from ._cdn_management_client_enums import HttpsRedirect -from ._cdn_management_client_enums import IdentityType -from ._cdn_management_client_enums import IsDeviceMatchConditionParametersMatchValuesItem -from ._cdn_management_client_enums import IsDeviceMatchConditionParametersTypeName -from ._cdn_management_client_enums import IsDeviceOperator -from ._cdn_management_client_enums import KeyVaultCertificateSourceParametersTypeName -from ._cdn_management_client_enums import KeyVaultSigningKeyParametersTypeName -from ._cdn_management_client_enums import LinkToDefaultDomain -from ._cdn_management_client_enums import LogMetric -from ._cdn_management_client_enums import LogMetricsGranularity -from ._cdn_management_client_enums import LogMetricsGroupBy -from ._cdn_management_client_enums import LogRanking -from ._cdn_management_client_enums import LogRankingMetric -from ._cdn_management_client_enums import ManagedRuleEnabledState -from ._cdn_management_client_enums import ManagedServiceIdentityType -from ._cdn_management_client_enums import MatchProcessingBehavior -from ._cdn_management_client_enums import MatchVariable -from ._cdn_management_client_enums import MetricsGranularity -from ._cdn_management_client_enums import MetricsSeriesUnit -from ._cdn_management_client_enums import MinimumTlsVersion -from ._cdn_management_client_enums import Operator -from ._cdn_management_client_enums import OptimizationType -from ._cdn_management_client_enums import OriginGroupOverrideActionParametersTypeName -from ._cdn_management_client_enums import OriginGroupProvisioningState -from ._cdn_management_client_enums import OriginGroupResourceState -from ._cdn_management_client_enums import OriginProvisioningState -from ._cdn_management_client_enums import OriginResourceState -from ._cdn_management_client_enums import ParamIndicator -from ._cdn_management_client_enums import PolicyEnabledState -from ._cdn_management_client_enums import PolicyMode -from ._cdn_management_client_enums import PolicyResourceState -from ._cdn_management_client_enums import PolicySettingsDefaultCustomBlockResponseStatusCode -from ._cdn_management_client_enums import PostArgsMatchConditionParametersTypeName -from ._cdn_management_client_enums import PostArgsOperator -from ._cdn_management_client_enums import PrivateEndpointStatus -from ._cdn_management_client_enums import ProbeProtocol -from ._cdn_management_client_enums import ProfileProvisioningState -from ._cdn_management_client_enums import ProfileResourceState -from ._cdn_management_client_enums import ProfileScrubbingState -from ._cdn_management_client_enums import ProtocolType -from ._cdn_management_client_enums import ProvisioningState -from ._cdn_management_client_enums import QueryStringBehavior -from ._cdn_management_client_enums import QueryStringCachingBehavior -from ._cdn_management_client_enums import QueryStringMatchConditionParametersTypeName -from ._cdn_management_client_enums import QueryStringOperator -from ._cdn_management_client_enums import RedirectType -from ._cdn_management_client_enums import RemoteAddressMatchConditionParametersTypeName -from ._cdn_management_client_enums import RemoteAddressOperator -from ._cdn_management_client_enums import RequestBodyMatchConditionParametersTypeName -from ._cdn_management_client_enums import RequestBodyOperator -from ._cdn_management_client_enums import RequestHeaderMatchConditionParametersTypeName -from ._cdn_management_client_enums import RequestHeaderOperator -from ._cdn_management_client_enums import RequestMethodMatchConditionParametersMatchValuesItem -from ._cdn_management_client_enums import RequestMethodMatchConditionParametersTypeName -from ._cdn_management_client_enums import RequestMethodOperator -from ._cdn_management_client_enums import RequestSchemeMatchConditionParametersMatchValuesItem -from ._cdn_management_client_enums import RequestSchemeMatchConditionParametersOperator -from ._cdn_management_client_enums import RequestSchemeMatchConditionParametersTypeName -from ._cdn_management_client_enums import RequestUriMatchConditionParametersTypeName -from ._cdn_management_client_enums import RequestUriOperator -from ._cdn_management_client_enums import ResourceType -from ._cdn_management_client_enums import ResourceUsageUnit -from ._cdn_management_client_enums import ResponseBasedDetectedErrorTypes -from ._cdn_management_client_enums import RouteConfigurationOverrideActionParametersTypeName -from ._cdn_management_client_enums import RuleCacheBehavior -from ._cdn_management_client_enums import RuleIsCompressionEnabled -from ._cdn_management_client_enums import RuleQueryStringCachingBehavior -from ._cdn_management_client_enums import ScrubbingRuleEntryMatchOperator -from ._cdn_management_client_enums import ScrubbingRuleEntryMatchVariable -from ._cdn_management_client_enums import ScrubbingRuleEntryState -from ._cdn_management_client_enums import SecretType -from ._cdn_management_client_enums import SecurityPolicyType -from ._cdn_management_client_enums import ServerPortMatchConditionParametersTypeName -from ._cdn_management_client_enums import ServerPortOperator -from ._cdn_management_client_enums import SharedPrivateLinkResourceStatus -from ._cdn_management_client_enums import SkuName -from ._cdn_management_client_enums import SocketAddrMatchConditionParametersTypeName -from ._cdn_management_client_enums import SocketAddrOperator -from ._cdn_management_client_enums import SslProtocol -from ._cdn_management_client_enums import SslProtocolMatchConditionParametersTypeName -from ._cdn_management_client_enums import SslProtocolOperator -from ._cdn_management_client_enums import Status -from ._cdn_management_client_enums import Transform -from ._cdn_management_client_enums import TransformType -from ._cdn_management_client_enums import UpdateRule -from ._cdn_management_client_enums import UrlFileExtensionMatchConditionParametersTypeName -from ._cdn_management_client_enums import UrlFileExtensionOperator -from ._cdn_management_client_enums import UrlFileNameMatchConditionParametersTypeName -from ._cdn_management_client_enums import UrlFileNameOperator -from ._cdn_management_client_enums import UrlPathMatchConditionParametersTypeName -from ._cdn_management_client_enums import UrlPathOperator -from ._cdn_management_client_enums import UrlRedirectActionParametersTypeName -from ._cdn_management_client_enums import UrlRewriteActionParametersTypeName -from ._cdn_management_client_enums import UrlSigningActionParametersTypeName -from ._cdn_management_client_enums import UsageUnit -from ._cdn_management_client_enums import WafAction -from ._cdn_management_client_enums import WafGranularity -from ._cdn_management_client_enums import WafMatchVariable -from ._cdn_management_client_enums import WafMetric -from ._cdn_management_client_enums import WafMetricsGranularity -from ._cdn_management_client_enums import WafMetricsSeriesUnit -from ._cdn_management_client_enums import WafRankingGroupBy -from ._cdn_management_client_enums import WafRankingType -from ._cdn_management_client_enums import WafRuleType +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AFDDomain, + AFDDomainHttpsCustomizedCipherSuiteSet, + AFDDomainHttpsParameters, + AFDDomainListResult, + AFDDomainProperties, + AFDDomainUpdateParameters, + AFDDomainUpdatePropertiesParameters, + AFDEndpoint, + AFDEndpointListResult, + AFDEndpointProperties, + AFDEndpointPropertiesUpdateParameters, + AFDEndpointUpdateParameters, + AFDOrigin, + AFDOriginGroup, + AFDOriginGroupListResult, + AFDOriginGroupProperties, + AFDOriginGroupUpdateParameters, + AFDOriginGroupUpdatePropertiesParameters, + AFDOriginListResult, + AFDOriginProperties, + AFDOriginUpdateParameters, + AFDOriginUpdatePropertiesParameters, + AFDStateProperties, + ActivatedResourceReference, + AfdErrorResponse, + AfdPurgeParameters, + AfdRouteCacheConfiguration, + AzureFirstPartyManagedCertificate, + AzureFirstPartyManagedCertificateParameters, + CacheConfiguration, + CacheExpirationActionParameters, + CacheKeyQueryStringActionParameters, + CanMigrateParameters, + CanMigrateResult, + CdnCertificateSourceParameters, + CdnEndpoint, + CdnManagedHttpsParameters, + CdnMigrationToAfdParameters, + CdnWebApplicationFirewallPolicy, + CdnWebApplicationFirewallPolicyList, + CdnWebApplicationFirewallPolicyPatchParameters, + Certificate, + CertificateSourceParameters, + CheckEndpointNameAvailabilityInput, + CheckEndpointNameAvailabilityOutput, + CheckHostNameAvailabilityInput, + CheckNameAvailabilityInput, + CheckNameAvailabilityOutput, + CidrIpAddress, + ClientPortMatchConditionParameters, + Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems, + Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems, + ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems, + CompressionSettings, + ContinentsResponse, + ContinentsResponseContinentsItem, + ContinentsResponseCountryOrRegionsItem, + CookiesMatchConditionParameters, + CustomDomain, + CustomDomainHttpsParameters, + CustomDomainListResult, + CustomDomainParameters, + CustomRule, + CustomRuleList, + CustomerCertificate, + CustomerCertificateParameters, + DeepCreatedCustomDomain, + DeepCreatedOrigin, + DeepCreatedOriginGroup, + DeliveryRule, + DeliveryRuleAction, + DeliveryRuleActionParameters, + DeliveryRuleCacheExpirationAction, + DeliveryRuleCacheKeyQueryStringAction, + DeliveryRuleClientPortCondition, + DeliveryRuleCondition, + DeliveryRuleConditionParameters, + DeliveryRuleCookiesCondition, + DeliveryRuleHostNameCondition, + DeliveryRuleHttpVersionCondition, + DeliveryRuleIsDeviceCondition, + DeliveryRulePostArgsCondition, + DeliveryRuleQueryStringCondition, + DeliveryRuleRemoteAddressCondition, + DeliveryRuleRequestBodyCondition, + DeliveryRuleRequestHeaderAction, + DeliveryRuleRequestHeaderCondition, + DeliveryRuleRequestMethodCondition, + DeliveryRuleRequestSchemeCondition, + DeliveryRuleRequestUriCondition, + DeliveryRuleResponseHeaderAction, + DeliveryRuleRouteConfigurationOverrideAction, + DeliveryRuleServerPortCondition, + DeliveryRuleSocketAddrCondition, + DeliveryRuleSslProtocolCondition, + DeliveryRuleUrlFileExtensionCondition, + DeliveryRuleUrlFileNameCondition, + DeliveryRuleUrlPathCondition, + DimensionProperties, + DomainValidationProperties, + EdgeNode, + EdgenodeResult, + Endpoint, + EndpointListResult, + EndpointProperties, + EndpointPropertiesUpdateParameters, + EndpointPropertiesUpdateParametersDeliveryPolicy, + EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink, + EndpointUpdateParameters, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + ErrorResponseAutoGenerated, + GeoFilter, + HeaderActionParameters, + HealthProbeParameters, + HostNameMatchConditionParameters, + HttpErrorRangeParameters, + HttpVersionMatchConditionParameters, + IpAddressGroup, + IsDeviceMatchConditionParameters, + KeyVaultCertificateSourceParameters, + KeyVaultSigningKeyParameters, + LoadBalancingSettingsParameters, + LoadParameters, + LogSpecification, + ManagedCertificate, + ManagedCertificateParameters, + ManagedRuleDefinition, + ManagedRuleGroupDefinition, + ManagedRuleGroupOverride, + ManagedRuleOverride, + ManagedRuleSet, + ManagedRuleSetDefinition, + ManagedRuleSetDefinitionList, + ManagedRuleSetList, + ManagedServiceIdentity, + MatchCondition, + MetricAvailability, + MetricSpecification, + MetricsResponse, + MetricsResponseSeriesItem, + MetricsResponseSeriesPropertiesItemsItem, + MigrateResult, + MigrationEndpointMapping, + MigrationErrorType, + MigrationParameters, + MigrationWebApplicationFirewallMapping, + Operation, + OperationDisplay, + OperationsListResult, + Origin, + OriginGroup, + OriginGroupListResult, + OriginGroupOverride, + OriginGroupOverrideAction, + OriginGroupOverrideActionParameters, + OriginGroupProperties, + OriginGroupUpdateParameters, + OriginGroupUpdatePropertiesParameters, + OriginListResult, + OriginProperties, + OriginUpdateParameters, + OriginUpdatePropertiesParameters, + PolicySettings, + PostArgsMatchConditionParameters, + Profile, + ProfileChangeSkuWafMapping, + ProfileListResult, + ProfileLogScrubbing, + ProfileScrubbingRules, + ProfileUpdateParameters, + ProfileUpgradeParameters, + ProxyResource, + PurgeParameters, + QueryStringMatchConditionParameters, + RankingsResponse, + RankingsResponseTablesItem, + RankingsResponseTablesPropertiesItemsItem, + RankingsResponseTablesPropertiesItemsMetricsItem, + RateLimitRule, + RateLimitRuleList, + RemoteAddressMatchConditionParameters, + RequestBodyMatchConditionParameters, + RequestHeaderMatchConditionParameters, + RequestMethodMatchConditionParameters, + RequestSchemeMatchConditionParameters, + RequestUriMatchConditionParameters, + Resource, + ResourceReference, + ResourceUsage, + ResourceUsageListResult, + ResourcesResponse, + ResourcesResponseCustomDomainsItem, + ResourcesResponseEndpointsItem, + ResourcesResponseEndpointsPropertiesItemsItem, + ResponseBasedOriginErrorDetectionParameters, + Route, + RouteConfigurationOverrideActionParameters, + RouteListResult, + RouteProperties, + RouteUpdateParameters, + RouteUpdatePropertiesParameters, + Rule, + RuleListResult, + RuleProperties, + RuleSet, + RuleSetListResult, + RuleSetProperties, + RuleUpdateParameters, + RuleUpdatePropertiesParameters, + Secret, + SecretListResult, + SecretParameters, + SecretProperties, + SecurityPolicy, + SecurityPolicyListResult, + SecurityPolicyProperties, + SecurityPolicyPropertiesParameters, + SecurityPolicyUpdateParameters, + SecurityPolicyWebApplicationFirewallAssociation, + SecurityPolicyWebApplicationFirewallParameters, + ServerPortMatchConditionParameters, + ServiceSpecification, + SharedPrivateLinkResourceProperties, + Sku, + SocketAddrMatchConditionParameters, + SslProtocolMatchConditionParameters, + SsoUri, + SupportedOptimizationTypesListResult, + SystemData, + TrackedResource, + UrlFileExtensionMatchConditionParameters, + UrlFileNameMatchConditionParameters, + UrlPathMatchConditionParameters, + UrlRedirectAction, + UrlRedirectActionParameters, + UrlRewriteAction, + UrlRewriteActionParameters, + UrlSigningAction, + UrlSigningActionParameters, + UrlSigningKey, + UrlSigningKeyParameters, + UrlSigningParamIdentifier, + Usage, + UsageName, + UsagesListResult, + UserAssignedIdentity, + UserManagedHttpsParameters, + ValidateCustomDomainInput, + ValidateCustomDomainOutput, + ValidateProbeInput, + ValidateProbeOutput, + ValidateSecretInput, + ValidateSecretOutput, + ValidationToken, + WafMetricsResponse, + WafMetricsResponseSeriesItem, + WafMetricsResponseSeriesPropertiesItemsItem, + WafRankingsResponse, + WafRankingsResponseDataItem, +) + +from ._cdn_management_client_enums import ( # type: ignore + AFDEndpointProtocols, + ActionType, + AfdCertificateType, + AfdCipherSuiteSetType, + AfdCustomizedCipherSuiteForTls12, + AfdCustomizedCipherSuiteForTls13, + AfdMinimumTlsVersion, + AfdProvisioningState, + AfdQueryStringCachingBehavior, + Algorithm, + AutoGeneratedDomainNameLabelScope, + CacheBehavior, + CacheType, + CanMigrateDefaultSku, + CertificateSource, + CertificateSourceParametersType, + CertificateType, + ClientPortOperator, + CookiesOperator, + CustomDomainResourceState, + CustomHttpsProvisioningState, + CustomHttpsProvisioningSubstate, + CustomRuleEnabledState, + DeleteRule, + DeliveryRuleActionEnum, + DeliveryRuleActionParametersType, + DeliveryRuleConditionParametersType, + DeploymentStatus, + DestinationProtocol, + DomainValidationState, + EnabledState, + EndpointProvisioningState, + EndpointResourceState, + ForwardingProtocol, + GeoFilterActions, + HeaderAction, + HealthProbeRequestType, + HostNameOperator, + HttpVersionOperator, + HttpsRedirect, + IdentityType, + IsDeviceMatchValue, + IsDeviceOperator, + KeyVaultSigningKeyParametersType, + LinkToDefaultDomain, + LogMetric, + LogMetricsGranularity, + LogMetricsGroupBy, + LogRanking, + LogRankingMetric, + ManagedRuleEnabledState, + ManagedServiceIdentityType, + MatchProcessingBehavior, + MatchVariable, + MetricsGranularity, + MetricsSeriesUnit, + MinimumTlsVersion, + Operator, + OptimizationType, + OriginGroupProvisioningState, + OriginGroupResourceState, + OriginProvisioningState, + OriginResourceState, + ParamIndicator, + PolicyEnabledState, + PolicyMode, + PolicyResourceState, + PolicySettingsDefaultCustomBlockResponseStatusCode, + PostArgsOperator, + PrivateEndpointStatus, + ProbeProtocol, + ProfileProvisioningState, + ProfileResourceState, + ProfileScrubbingState, + ProtocolType, + ProvisioningState, + QueryStringBehavior, + QueryStringCachingBehavior, + QueryStringOperator, + RedirectType, + RemoteAddressOperator, + RequestBodyOperator, + RequestHeaderOperator, + RequestMethodMatchValue, + RequestMethodOperator, + RequestSchemeMatchConditionParametersOperator, + RequestSchemeMatchValue, + RequestUriOperator, + ResourceType, + ResourceUsageUnit, + ResponseBasedDetectedErrorTypes, + RuleCacheBehavior, + RuleIsCompressionEnabled, + RuleQueryStringCachingBehavior, + ScrubbingRuleEntryMatchOperator, + ScrubbingRuleEntryMatchVariable, + ScrubbingRuleEntryState, + SecretType, + SecurityPolicyType, + ServerPortOperator, + SharedPrivateLinkResourceStatus, + SkuName, + SocketAddrOperator, + SslProtocol, + SslProtocolOperator, + Status, + Transform, + TransformType, + UpdateRule, + UrlFileExtensionOperator, + UrlFileNameOperator, + UrlPathOperator, + UsageUnit, + WafAction, + WafGranularity, + WafMatchVariable, + WafMetric, + WafMetricsGranularity, + WafMetricsSeriesUnit, + WafRankingGroupBy, + WafRankingType, + WafRuleType, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "AFDDomain", + "AFDDomainHttpsCustomizedCipherSuiteSet", "AFDDomainHttpsParameters", "AFDDomainListResult", "AFDDomainProperties", @@ -447,10 +443,12 @@ "CdnCertificateSourceParameters", "CdnEndpoint", "CdnManagedHttpsParameters", + "CdnMigrationToAfdParameters", "CdnWebApplicationFirewallPolicy", "CdnWebApplicationFirewallPolicyList", "CdnWebApplicationFirewallPolicyPatchParameters", "Certificate", + "CertificateSourceParameters", "CheckEndpointNameAvailabilityInput", "CheckEndpointNameAvailabilityOutput", "CheckHostNameAvailabilityInput", @@ -479,10 +477,12 @@ "DeepCreatedOriginGroup", "DeliveryRule", "DeliveryRuleAction", + "DeliveryRuleActionParameters", "DeliveryRuleCacheExpirationAction", "DeliveryRuleCacheKeyQueryStringAction", "DeliveryRuleClientPortCondition", "DeliveryRuleCondition", + "DeliveryRuleConditionParameters", "DeliveryRuleCookiesCondition", "DeliveryRuleHostNameCondition", "DeliveryRuleHttpVersionCondition", @@ -518,6 +518,7 @@ "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", + "ErrorResponseAutoGenerated", "GeoFilter", "HeaderActionParameters", "HealthProbeParameters", @@ -549,6 +550,7 @@ "MetricsResponseSeriesItem", "MetricsResponseSeriesPropertiesItemsItem", "MigrateResult", + "MigrationEndpointMapping", "MigrationErrorType", "MigrationParameters", "MigrationWebApplicationFirewallMapping", @@ -668,22 +670,21 @@ "AFDEndpointProtocols", "ActionType", "AfdCertificateType", + "AfdCipherSuiteSetType", + "AfdCustomizedCipherSuiteForTls12", + "AfdCustomizedCipherSuiteForTls13", "AfdMinimumTlsVersion", "AfdProvisioningState", "AfdQueryStringCachingBehavior", "Algorithm", "AutoGeneratedDomainNameLabelScope", "CacheBehavior", - "CacheExpirationActionParametersTypeName", - "CacheKeyQueryStringActionParametersTypeName", "CacheType", "CanMigrateDefaultSku", - "CdnCertificateSourceParametersTypeName", "CertificateSource", + "CertificateSourceParametersType", "CertificateType", - "ClientPortMatchConditionParametersTypeName", "ClientPortOperator", - "CookiesMatchConditionParametersTypeName", "CookiesOperator", "CustomDomainResourceState", "CustomHttpsProvisioningState", @@ -691,6 +692,8 @@ "CustomRuleEnabledState", "DeleteRule", "DeliveryRuleActionEnum", + "DeliveryRuleActionParametersType", + "DeliveryRuleConditionParametersType", "DeploymentStatus", "DestinationProtocol", "DomainValidationState", @@ -700,19 +703,14 @@ "ForwardingProtocol", "GeoFilterActions", "HeaderAction", - "HeaderActionParametersTypeName", "HealthProbeRequestType", - "HostNameMatchConditionParametersTypeName", "HostNameOperator", - "HttpVersionMatchConditionParametersTypeName", "HttpVersionOperator", "HttpsRedirect", "IdentityType", - "IsDeviceMatchConditionParametersMatchValuesItem", - "IsDeviceMatchConditionParametersTypeName", + "IsDeviceMatchValue", "IsDeviceOperator", - "KeyVaultCertificateSourceParametersTypeName", - "KeyVaultSigningKeyParametersTypeName", + "KeyVaultSigningKeyParametersType", "LinkToDefaultDomain", "LogMetric", "LogMetricsGranularity", @@ -728,7 +726,6 @@ "MinimumTlsVersion", "Operator", "OptimizationType", - "OriginGroupOverrideActionParametersTypeName", "OriginGroupProvisioningState", "OriginGroupResourceState", "OriginProvisioningState", @@ -738,7 +735,6 @@ "PolicyMode", "PolicyResourceState", "PolicySettingsDefaultCustomBlockResponseStatusCode", - "PostArgsMatchConditionParametersTypeName", "PostArgsOperator", "PrivateEndpointStatus", "ProbeProtocol", @@ -749,27 +745,19 @@ "ProvisioningState", "QueryStringBehavior", "QueryStringCachingBehavior", - "QueryStringMatchConditionParametersTypeName", "QueryStringOperator", "RedirectType", - "RemoteAddressMatchConditionParametersTypeName", "RemoteAddressOperator", - "RequestBodyMatchConditionParametersTypeName", "RequestBodyOperator", - "RequestHeaderMatchConditionParametersTypeName", "RequestHeaderOperator", - "RequestMethodMatchConditionParametersMatchValuesItem", - "RequestMethodMatchConditionParametersTypeName", + "RequestMethodMatchValue", "RequestMethodOperator", - "RequestSchemeMatchConditionParametersMatchValuesItem", "RequestSchemeMatchConditionParametersOperator", - "RequestSchemeMatchConditionParametersTypeName", - "RequestUriMatchConditionParametersTypeName", + "RequestSchemeMatchValue", "RequestUriOperator", "ResourceType", "ResourceUsageUnit", "ResponseBasedDetectedErrorTypes", - "RouteConfigurationOverrideActionParametersTypeName", "RuleCacheBehavior", "RuleIsCompressionEnabled", "RuleQueryStringCachingBehavior", @@ -778,28 +766,19 @@ "ScrubbingRuleEntryState", "SecretType", "SecurityPolicyType", - "ServerPortMatchConditionParametersTypeName", "ServerPortOperator", "SharedPrivateLinkResourceStatus", "SkuName", - "SocketAddrMatchConditionParametersTypeName", "SocketAddrOperator", "SslProtocol", - "SslProtocolMatchConditionParametersTypeName", "SslProtocolOperator", "Status", "Transform", "TransformType", "UpdateRule", - "UrlFileExtensionMatchConditionParametersTypeName", "UrlFileExtensionOperator", - "UrlFileNameMatchConditionParametersTypeName", "UrlFileNameOperator", - "UrlPathMatchConditionParametersTypeName", "UrlPathOperator", - "UrlRedirectActionParametersTypeName", - "UrlRewriteActionParametersTypeName", - "UrlSigningActionParametersTypeName", "UsageUnit", "WafAction", "WafGranularity", @@ -811,5 +790,5 @@ "WafRankingType", "WafRuleType", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py index d0164f2b6f7b..d9530f123e1e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -27,6 +28,33 @@ class AfdCertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): AZURE_FIRST_PARTY_MANAGED_CERTIFICATE = "AzureFirstPartyManagedCertificate" +class AfdCipherSuiteSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """cipher suite set type that will be used for Https.""" + + CUSTOMIZED = "Customized" + TLS10_2019 = "TLS10_2019" + TLS12_2022 = "TLS12_2022" + TLS12_2023 = "TLS12_2023" + + +class AfdCustomizedCipherSuiteForTls12(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AfdCustomizedCipherSuiteForTls12.""" + + ECDHE_RSA_AES128_GCM_SHA256 = "ECDHE_RSA_AES128_GCM_SHA256" + ECDHE_RSA_AES256_GCM_SHA384 = "ECDHE_RSA_AES256_GCM_SHA384" + DHE_RSA_AES256_GCM_SHA384 = "DHE_RSA_AES256_GCM_SHA384" + DHE_RSA_AES128_GCM_SHA256 = "DHE_RSA_AES128_GCM_SHA256" + ECDHE_RSA_AES128_SHA256 = "ECDHE_RSA_AES128_SHA256" + ECDHE_RSA_AES256_SHA384 = "ECDHE_RSA_AES256_SHA384" + + +class AfdCustomizedCipherSuiteForTls13(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AfdCustomizedCipherSuiteForTls13.""" + + TLS_AES128_GCM_SHA256 = "TLS_AES_128_GCM_SHA256" + TLS_AES256_GCM_SHA384 = "TLS_AES_256_GCM_SHA384" + + class AFDEndpointProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Supported protocols for the customer's endpoint.""" @@ -35,10 +63,11 @@ class AFDEndpointProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AfdMinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """TLS protocol version that will be used for Https.""" + """TLS protocol version that will be used for Https when cipherSuiteSetType is Customized.""" TLS10 = "TLS10" TLS12 = "TLS12" + TLS13 = "TLS13" class AfdProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -86,20 +115,6 @@ class CacheBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): SET_IF_MISSING = "SetIfMissing" -class CacheExpirationActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CacheExpirationActionParametersTypeName.""" - - DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS = "DeliveryRuleCacheExpirationActionParameters" - - -class CacheKeyQueryStringActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CacheKeyQueryStringActionParametersTypeName.""" - - DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS = ( - "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" - ) - - class CacheType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level at which the content needs to be cached.""" @@ -113,12 +128,6 @@ class CanMigrateDefaultSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): PREMIUM_AZURE_FRONT_DOOR = "Premium_AzureFrontDoor" -class CdnCertificateSourceParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CdnCertificateSourceParametersTypeName.""" - - CDN_CERTIFICATE_SOURCE_PARAMETERS = "CdnCertificateSourceParameters" - - class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the source of the SSL certificate.""" @@ -126,6 +135,13 @@ class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): CDN = "Cdn" +class CertificateSourceParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CertificateSourceParametersType.""" + + CDN_CERTIFICATE_SOURCE_PARAMETERS = "CdnCertificateSourceParameters" + KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS = "KeyVaultCertificateSourceParameters" + + class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of certificate used.""" @@ -133,12 +149,6 @@ class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEDICATED = "Dedicated" -class ClientPortMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ClientPortMatchConditionParametersTypeName.""" - - DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS = "DeliveryRuleClientPortConditionParameters" - - class ClientPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -154,12 +164,6 @@ class ClientPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class CookiesMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CookiesMatchConditionParametersTypeName.""" - - DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS = "DeliveryRuleCookiesConditionParameters" - - class CookiesOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -239,6 +243,47 @@ class DeliveryRuleActionEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): ROUTE_CONFIGURATION_OVERRIDE = "RouteConfigurationOverride" +class DeliveryRuleActionParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DeliveryRuleActionParametersType.""" + + DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS = "DeliveryRuleUrlRedirectActionParameters" + DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS = "DeliveryRuleUrlSigningActionParameters" + DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS = "DeliveryRuleOriginGroupOverrideActionParameters" + DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS = "DeliveryRuleUrlRewriteActionParameters" + DELIVERY_RULE_HEADER_ACTION_PARAMETERS = "DeliveryRuleHeaderActionParameters" + DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS = "DeliveryRuleCacheExpirationActionParameters" + DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS = ( + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" + ) + DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS = ( + "DeliveryRuleRouteConfigurationOverrideActionParameters" + ) + + +class DeliveryRuleConditionParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DeliveryRuleConditionParametersType.""" + + DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS = "DeliveryRuleRemoteAddressConditionParameters" + DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS = "DeliveryRuleRequestMethodConditionParameters" + DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS = "DeliveryRuleQueryStringConditionParameters" + DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS = "DeliveryRulePostArgsConditionParameters" + DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS = "DeliveryRuleRequestUriConditionParameters" + DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS = "DeliveryRuleRequestHeaderConditionParameters" + DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS = "DeliveryRuleRequestBodyConditionParameters" + DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS = "DeliveryRuleRequestSchemeConditionParameters" + DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlPathMatchConditionParameters" + DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS = "DeliveryRuleUrlFilenameConditionParameters" + DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS = "DeliveryRuleHttpVersionConditionParameters" + DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS = "DeliveryRuleCookiesConditionParameters" + DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS = "DeliveryRuleIsDeviceConditionParameters" + DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS = "DeliveryRuleSocketAddrConditionParameters" + DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS = "DeliveryRuleClientPortConditionParameters" + DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS = "DeliveryRuleServerPortConditionParameters" + DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS = "DeliveryRuleHostNameConditionParameters" + DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS = "DeliveryRuleSslProtocolConditionParameters" + + class DeploymentStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """DeploymentStatus.""" @@ -323,12 +368,6 @@ class HeaderAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "Delete" -class HeaderActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HeaderActionParametersTypeName.""" - - DELIVERY_RULE_HEADER_ACTION_PARAMETERS = "DeliveryRuleHeaderActionParameters" - - class HealthProbeRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of health probe request that is made.""" @@ -337,12 +376,6 @@ class HealthProbeRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): HEAD = "HEAD" -class HostNameMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HostNameMatchConditionParametersTypeName.""" - - DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS = "DeliveryRuleHostNameConditionParameters" - - class HostNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -367,12 +400,6 @@ class HttpsRedirect(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" -class HttpVersionMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HttpVersionMatchConditionParametersTypeName.""" - - DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS = "DeliveryRuleHttpVersionConditionParameters" - - class HttpVersionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -388,33 +415,21 @@ class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "key" -class IsDeviceMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IsDeviceMatchConditionParametersMatchValuesItem.""" +class IsDeviceMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IsDeviceMatchValue.""" MOBILE = "Mobile" DESKTOP = "Desktop" -class IsDeviceMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IsDeviceMatchConditionParametersTypeName.""" - - DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS = "DeliveryRuleIsDeviceConditionParameters" - - class IsDeviceOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" -class KeyVaultCertificateSourceParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KeyVaultCertificateSourceParametersTypeName.""" - - KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS = "KeyVaultCertificateSourceParameters" - - -class KeyVaultSigningKeyParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KeyVaultSigningKeyParametersTypeName.""" +class KeyVaultSigningKeyParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KeyVaultSigningKeyParametersType.""" KEY_VAULT_SIGNING_KEY_PARAMETERS = "KeyVaultSigningKeyParameters" @@ -501,8 +516,9 @@ class MatchProcessingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): If not present, defaults to Continue. """ - CONTINUE_ENUM = "Continue" + CONTINUE = "Continue" STOP = "Stop" + CONTINUE_ENUM = "Continue" class MatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -583,12 +599,6 @@ class OptimizationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DYNAMIC_SITE_ACCELERATION = "DynamicSiteAcceleration" -class OriginGroupOverrideActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """OriginGroupOverrideActionParametersTypeName.""" - - DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS = "DeliveryRuleOriginGroupOverrideActionParameters" - - class OriginGroupProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the origin group.""" @@ -670,12 +680,6 @@ class PolicySettingsDefaultCustomBlockResponseStatusCode(int, Enum, metaclass=Ca FOUR_HUNDRED_TWENTY_NINE = 429 -class PostArgsMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PostArgsMatchConditionParametersTypeName.""" - - DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS = "DeliveryRulePostArgsConditionParameters" - - class PostArgsOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -776,12 +780,6 @@ class QueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): NOT_SET = "NotSet" -class QueryStringMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """QueryStringMatchConditionParametersTypeName.""" - - DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS = "DeliveryRuleQueryStringConditionParameters" - - class QueryStringOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -806,12 +804,6 @@ class RedirectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): PERMANENT_REDIRECT = "PermanentRedirect" -class RemoteAddressMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RemoteAddressMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS = "DeliveryRuleRemoteAddressConditionParameters" - - class RemoteAddressOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -820,12 +812,6 @@ class RemoteAddressOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_MATCH = "GeoMatch" -class RequestBodyMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestBodyMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS = "DeliveryRuleRequestBodyConditionParameters" - - class RequestBodyOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -841,12 +827,6 @@ class RequestBodyOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class RequestHeaderMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestHeaderMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS = "DeliveryRuleRequestHeaderConditionParameters" - - class RequestHeaderOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -862,8 +842,8 @@ class RequestHeaderOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class RequestMethodMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestMethodMatchConditionParametersMatchValuesItem.""" +class RequestMethodMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RequestMethodMatchValue.""" GET = "GET" HEAD = "HEAD" @@ -874,41 +854,23 @@ class RequestMethodMatchConditionParametersMatchValuesItem(str, Enum, metaclass= TRACE = "TRACE" -class RequestMethodMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestMethodMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS = "DeliveryRuleRequestMethodConditionParameters" - - class RequestMethodOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" -class RequestSchemeMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestSchemeMatchConditionParametersMatchValuesItem.""" - - HTTP = "HTTP" - HTTPS = "HTTPS" - - class RequestSchemeMatchConditionParametersOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" -class RequestSchemeMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestSchemeMatchConditionParametersTypeName.""" +class RequestSchemeMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RequestSchemeMatchValue.""" - DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS = "DeliveryRuleRequestSchemeConditionParameters" - - -class RequestUriMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestUriMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS = "DeliveryRuleRequestUriConditionParameters" + HTTP = "HTTP" + HTTPS = "HTTPS" class RequestUriOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -947,14 +909,6 @@ class ResponseBasedDetectedErrorTypes(str, Enum, metaclass=CaseInsensitiveEnumMe TCP_AND_HTTP_ERRORS = "TcpAndHttpErrors" -class RouteConfigurationOverrideActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RouteConfigurationOverrideActionParametersTypeName.""" - - DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS = ( - "DeliveryRuleRouteConfigurationOverrideActionParameters" - ) - - class RuleCacheBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Caching behavior for the requests.""" @@ -1023,12 +977,6 @@ class SecurityPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): WEB_APPLICATION_FIREWALL = "WebApplicationFirewall" -class ServerPortMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ServerPortMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS = "DeliveryRuleServerPortConditionParameters" - - class ServerPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1074,12 +1022,6 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_PLUS_AVG_BAND_WIDTH_CHINA_CDN = "StandardPlus_AvgBandWidth_ChinaCdn" -class SocketAddrMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SocketAddrMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS = "DeliveryRuleSocketAddrConditionParameters" - - class SocketAddrOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1095,12 +1037,6 @@ class SslProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): TL_SV1_2 = "TLSv1.2" -class SslProtocolMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SslProtocolMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS = "DeliveryRuleSslProtocolConditionParameters" - - class SslProtocolOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1144,12 +1080,6 @@ class UpdateRule(str, Enum, metaclass=CaseInsensitiveEnumMeta): NO_ACTION = "NoAction" -class UrlFileExtensionMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlFileExtensionMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlFileExtensionMatchConditionParameters" - - class UrlFileExtensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1165,12 +1095,6 @@ class UrlFileExtensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class UrlFileNameMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlFileNameMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS = "DeliveryRuleUrlFilenameConditionParameters" - - class UrlFileNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1186,12 +1110,6 @@ class UrlFileNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class UrlPathMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlPathMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlPathMatchConditionParameters" - - class UrlPathOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1208,24 +1126,6 @@ class UrlPathOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class UrlRedirectActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlRedirectActionParametersTypeName.""" - - DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS = "DeliveryRuleUrlRedirectActionParameters" - - -class UrlRewriteActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlRewriteActionParametersTypeName.""" - - DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS = "DeliveryRuleUrlRewriteActionParameters" - - -class UrlSigningActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlSigningActionParametersTypeName.""" - - DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS = "DeliveryRuleUrlSigningActionParameters" - - class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An enum describing the unit of measurement.""" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py index e5fd01153680..e8c405d209fd 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py @@ -1,5 +1,5 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 -# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -10,10 +10,9 @@ import datetime from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from .. import _serialization +from .._utils import serialization as _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -44,7 +43,7 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin """ super().__init__(**kwargs) self.id = id - self.is_active = None + self.is_active: Optional[bool] = None class Resource(_serialization.Model): @@ -79,10 +78,10 @@ class Resource(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None + 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): @@ -102,7 +101,7 @@ class ProxyResource(Resource): """ -class AFDDomain(ProxyResource): # pylint: disable=too-many-instance-attributes +class AFDDomain(ProxyResource): """Friendly domain name mapping to the endpoint hostname that the customer provides for branding purposes, e.g. www.contoso.com. @@ -204,16 +203,57 @@ def __init__( :paramtype extended_properties: dict[str, str] """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.tls_settings = tls_settings self.azure_dns_zone = azure_dns_zone self.pre_validated_custom_domain_resource_id = pre_validated_custom_domain_resource_id - self.provisioning_state = None - self.deployment_status = None - self.domain_validation_state = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.domain_validation_state: Optional[Union[str, "_models.DomainValidationState"]] = None self.host_name = host_name self.extended_properties = extended_properties - self.validation_properties = None + self.validation_properties: Optional["_models.DomainValidationProperties"] = None + + +class AFDDomainHttpsCustomizedCipherSuiteSet(_serialization.Model): + """Customized cipher suite set object that will be used for Https when cipherSuiteSetType is + Customized. + + :ivar cipher_suite_set_for_tls12: Cipher suites for TLS 1.2. Required at least one in + minimumTlsVersion TLS 1.2. + :vartype cipher_suite_set_for_tls12: list[str or + ~azure.mgmt.cdn.models.AfdCustomizedCipherSuiteForTls12] + :ivar cipher_suite_set_for_tls13: Cipher suites for TLS 1.3. Required at least one in + minimumTlsVersion TLS 1.2, TLS 1.3. + :vartype cipher_suite_set_for_tls13: list[str or + ~azure.mgmt.cdn.models.AfdCustomizedCipherSuiteForTls13] + """ + + _attribute_map = { + "cipher_suite_set_for_tls12": {"key": "cipherSuiteSetForTls12", "type": "[str]"}, + "cipher_suite_set_for_tls13": {"key": "cipherSuiteSetForTls13", "type": "[str]"}, + } + + def __init__( + self, + *, + cipher_suite_set_for_tls12: Optional[List[Union[str, "_models.AfdCustomizedCipherSuiteForTls12"]]] = None, + cipher_suite_set_for_tls13: Optional[List[Union[str, "_models.AfdCustomizedCipherSuiteForTls13"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword cipher_suite_set_for_tls12: Cipher suites for TLS 1.2. Required at least one in + minimumTlsVersion TLS 1.2. + :paramtype cipher_suite_set_for_tls12: list[str or + ~azure.mgmt.cdn.models.AfdCustomizedCipherSuiteForTls12] + :keyword cipher_suite_set_for_tls13: Cipher suites for TLS 1.3. Required at least one in + minimumTlsVersion TLS 1.2, TLS 1.3. + :paramtype cipher_suite_set_for_tls13: list[str or + ~azure.mgmt.cdn.models.AfdCustomizedCipherSuiteForTls13] + """ + super().__init__(**kwargs) + self.cipher_suite_set_for_tls12 = cipher_suite_set_for_tls12 + self.cipher_suite_set_for_tls13 = cipher_suite_set_for_tls13 class AFDDomainHttpsParameters(_serialization.Model): @@ -224,9 +264,16 @@ class AFDDomainHttpsParameters(_serialization.Model): :ivar certificate_type: Defines the source of the SSL certificate. Required. Known values are: "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". :vartype certificate_type: str or ~azure.mgmt.cdn.models.AfdCertificateType - :ivar minimum_tls_version: TLS protocol version that will be used for Https. Known values are: - "TLS10" and "TLS12". + :ivar cipher_suite_set_type: cipher suite set type that will be used for Https. Known values + are: "Customized", "TLS10_2019", "TLS12_2022", and "TLS12_2023". + :vartype cipher_suite_set_type: str or ~azure.mgmt.cdn.models.AfdCipherSuiteSetType + :ivar minimum_tls_version: TLS protocol version that will be used for Https when + cipherSuiteSetType is Customized. Known values are: "TLS10", "TLS12", and "TLS13". :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.AfdMinimumTlsVersion + :ivar customized_cipher_suite_set: Customized cipher suites object that will be used for Https + when cipherSuiteSetType is Customized. + :vartype customized_cipher_suite_set: + ~azure.mgmt.cdn.models.AFDDomainHttpsCustomizedCipherSuiteSet :ivar secret: Resource reference to the secret. ie. subs/rg/profile/secret. :vartype secret: ~azure.mgmt.cdn.models.ResourceReference """ @@ -237,7 +284,12 @@ class AFDDomainHttpsParameters(_serialization.Model): _attribute_map = { "certificate_type": {"key": "certificateType", "type": "str"}, + "cipher_suite_set_type": {"key": "cipherSuiteSetType", "type": "str"}, "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, + "customized_cipher_suite_set": { + "key": "customizedCipherSuiteSet", + "type": "AFDDomainHttpsCustomizedCipherSuiteSet", + }, "secret": {"key": "secret", "type": "ResourceReference"}, } @@ -245,7 +297,9 @@ def __init__( self, *, certificate_type: Union[str, "_models.AfdCertificateType"], + cipher_suite_set_type: Optional[Union[str, "_models.AfdCipherSuiteSetType"]] = None, minimum_tls_version: Optional[Union[str, "_models.AfdMinimumTlsVersion"]] = None, + customized_cipher_suite_set: Optional["_models.AFDDomainHttpsCustomizedCipherSuiteSet"] = None, secret: Optional["_models.ResourceReference"] = None, **kwargs: Any ) -> None: @@ -253,15 +307,24 @@ def __init__( :keyword certificate_type: Defines the source of the SSL certificate. Required. Known values are: "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". :paramtype certificate_type: str or ~azure.mgmt.cdn.models.AfdCertificateType - :keyword minimum_tls_version: TLS protocol version that will be used for Https. Known values - are: "TLS10" and "TLS12". + :keyword cipher_suite_set_type: cipher suite set type that will be used for Https. Known values + are: "Customized", "TLS10_2019", "TLS12_2022", and "TLS12_2023". + :paramtype cipher_suite_set_type: str or ~azure.mgmt.cdn.models.AfdCipherSuiteSetType + :keyword minimum_tls_version: TLS protocol version that will be used for Https when + cipherSuiteSetType is Customized. Known values are: "TLS10", "TLS12", and "TLS13". :paramtype minimum_tls_version: str or ~azure.mgmt.cdn.models.AfdMinimumTlsVersion + :keyword customized_cipher_suite_set: Customized cipher suites object that will be used for + Https when cipherSuiteSetType is Customized. + :paramtype customized_cipher_suite_set: + ~azure.mgmt.cdn.models.AFDDomainHttpsCustomizedCipherSuiteSet :keyword secret: Resource reference to the secret. ie. subs/rg/profile/secret. :paramtype secret: ~azure.mgmt.cdn.models.ResourceReference """ super().__init__(**kwargs) self.certificate_type = certificate_type + self.cipher_suite_set_type = cipher_suite_set_type self.minimum_tls_version = minimum_tls_version + self.customized_cipher_suite_set = customized_cipher_suite_set self.secret = secret @@ -292,7 +355,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.AFDDomain"]] = None self.next_link = next_link @@ -322,8 +385,8 @@ class AFDStateProperties(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None class AFDDomainUpdatePropertiesParameters(_serialization.Model): @@ -378,7 +441,7 @@ def __init__( :paramtype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.tls_settings = tls_settings self.azure_dns_zone = azure_dns_zone self.pre_validated_custom_domain_resource_id = pre_validated_custom_domain_resource_id @@ -477,13 +540,13 @@ def __init__( pre_validated_custom_domain_resource_id=pre_validated_custom_domain_resource_id, **kwargs ) - self.provisioning_state = None - self.deployment_status = None - self.domain_validation_state = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.domain_validation_state: Optional[Union[str, "_models.DomainValidationState"]] = None self.host_name = host_name self.extended_properties = extended_properties - self.validation_properties = None - self.profile_name = None + self.validation_properties: Optional["_models.DomainValidationProperties"] = None + self.profile_name: Optional[str] = None self.tls_settings = tls_settings self.azure_dns_zone = azure_dns_zone self.pre_validated_custom_domain_resource_id = pre_validated_custom_domain_resource_id @@ -541,7 +604,7 @@ def __init__( :paramtype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.tls_settings = tls_settings self.azure_dns_zone = azure_dns_zone self.pre_validated_custom_domain_resource_id = pre_validated_custom_domain_resource_id @@ -597,7 +660,7 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.tags = tags -class AFDEndpoint(TrackedResource): # pylint: disable=too-many-instance-attributes +class AFDEndpoint(TrackedResource): """Azure Front Door endpoint is the entity within a Azure Front Door profile containing configuration information such as origin, protocol, content caching and delivery behavior. The AzureFrontDoor endpoint uses the URL format :code:``.azureedge.net. @@ -695,11 +758,11 @@ def __init__( ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope """ super().__init__(location=location, tags=tags, **kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.enabled_state = enabled_state - self.provisioning_state = None - self.deployment_status = None - self.host_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.host_name: Optional[str] = None self.auto_generated_domain_name_label_scope = auto_generated_domain_name_label_scope @@ -730,7 +793,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.AFDEndpoint"]] = None self.next_link = next_link @@ -762,7 +825,7 @@ def __init__(self, *, enabled_state: Optional[Union[str, "_models.EnabledState"] :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.enabled_state = enabled_state @@ -828,11 +891,11 @@ def __init__( ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope """ super().__init__(enabled_state=enabled_state, **kwargs) - self.provisioning_state = None - self.deployment_status = None - self.host_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.host_name: Optional[str] = None self.auto_generated_domain_name_label_scope = auto_generated_domain_name_label_scope - self.profile_name = None + self.profile_name: Optional[str] = None self.enabled_state = enabled_state @@ -876,7 +939,7 @@ def __init__( """ super().__init__(**kwargs) self.tags = tags - self.profile_name = None + self.profile_name: Optional[str] = None self.enabled_state = enabled_state @@ -901,7 +964,7 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error -class AFDOrigin(ProxyResource): # pylint: disable=too-many-instance-attributes +class AFDOrigin(ProxyResource): """Azure Front Door origin is the source of the content being delivered via Azure Front Door. When the edge nodes represented by an endpoint do not have the requested content cached, they attempt to fetch it from one or more of the configured origins. @@ -1044,7 +1107,7 @@ def __init__( :paramtype enforce_certificate_name_check: bool """ super().__init__(**kwargs) - self.origin_group_name = None + self.origin_group_name: Optional[str] = None self.azure_origin = azure_origin self.host_name = host_name self.http_port = http_port @@ -1055,11 +1118,11 @@ def __init__( self.shared_private_link_resource = shared_private_link_resource self.enabled_state = enabled_state self.enforce_certificate_name_check = enforce_certificate_name_check - self.provisioning_state = None - self.deployment_status = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None -class AFDOriginGroup(ProxyResource): # pylint: disable=too-many-instance-attributes +class AFDOriginGroup(ProxyResource): """AFDOrigin group comprising of origins is used for load balancing to origins when the content cannot be served from Azure Front Door. @@ -1150,15 +1213,15 @@ def __init__( :paramtype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.load_balancing_settings = load_balancing_settings self.health_probe_settings = health_probe_settings self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( traffic_restoration_time_to_healed_or_new_endpoints_in_minutes ) self.session_affinity_state = session_affinity_state - self.provisioning_state = None - self.deployment_status = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None class AFDOriginGroupListResult(_serialization.Model): @@ -1188,7 +1251,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.AFDOriginGroup"]] = None self.next_link = next_link @@ -1253,7 +1316,7 @@ def __init__( :paramtype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.load_balancing_settings = load_balancing_settings self.health_probe_settings = health_probe_settings self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( @@ -1339,9 +1402,9 @@ def __init__( session_affinity_state=session_affinity_state, **kwargs ) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.profile_name: Optional[str] = None self.load_balancing_settings = load_balancing_settings self.health_probe_settings = health_probe_settings self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( @@ -1414,7 +1477,7 @@ def __init__( :paramtype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.load_balancing_settings = load_balancing_settings self.health_probe_settings = health_probe_settings self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( @@ -1450,11 +1513,11 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.AFDOrigin"]] = None self.next_link = next_link -class AFDOriginUpdatePropertiesParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class AFDOriginUpdatePropertiesParameters(_serialization.Model): """The JSON object that contains the properties of the origin. Variables are only populated by the server, and will be ignored when sending a request. @@ -1569,7 +1632,7 @@ def __init__( :paramtype enforce_certificate_name_check: bool """ super().__init__(**kwargs) - self.origin_group_name = None + self.origin_group_name: Optional[str] = None self.azure_origin = azure_origin self.host_name = host_name self.http_port = http_port @@ -1582,9 +1645,7 @@ def __init__( self.enforce_certificate_name_check = enforce_certificate_name_check -class AFDOriginProperties( - AFDOriginUpdatePropertiesParameters, AFDStateProperties -): # pylint: disable=too-many-instance-attributes +class AFDOriginProperties(AFDOriginUpdatePropertiesParameters, AFDStateProperties): """The JSON object that contains the properties of the origin. Variables are only populated by the server, and will be ignored when sending a request. @@ -1721,9 +1782,9 @@ def __init__( enforce_certificate_name_check=enforce_certificate_name_check, **kwargs ) - self.provisioning_state = None - self.deployment_status = None - self.origin_group_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.origin_group_name: Optional[str] = None self.azure_origin = azure_origin self.host_name = host_name self.http_port = http_port @@ -1736,7 +1797,7 @@ def __init__( self.enforce_certificate_name_check = enforce_certificate_name_check -class AFDOriginUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class AFDOriginUpdateParameters(_serialization.Model): """AFDOrigin properties needed for origin update. Variables are only populated by the server, and will be ignored when sending a request. @@ -1851,7 +1912,7 @@ def __init__( :paramtype enforce_certificate_name_check: bool """ super().__init__(**kwargs) - self.origin_group_name = None + self.origin_group_name: Optional[str] = None self.azure_origin = azure_origin self.host_name = host_name self.http_port = http_port @@ -1981,8 +2042,8 @@ def __init__(self, *, type: Optional[Union[str, "_models.SecretType"]] = None, * """ super().__init__(**kwargs) self.type = type - self.subject = None - self.expiration_date = None + self.subject: Optional[str] = None + self.expiration_date: Optional[str] = None class AzureFirstPartyManagedCertificate(Certificate): @@ -2051,7 +2112,7 @@ class AzureFirstPartyManagedCertificateParameters(SecretParameters): # pylint: :vartype type: str or ~azure.mgmt.cdn.models.SecretType :ivar secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar subject: Subject name in the certificate. :vartype subject: str @@ -2091,12 +2152,12 @@ def __init__(self, *, subject_alternative_names: Optional[List[str]] = None, **k """ super().__init__(**kwargs) self.type: str = "AzureFirstPartyManagedCertificate" - self.secret_source = None - self.subject = None - self.expiration_date = None - self.certificate_authority = None + self.secret_source: Optional["_models.ResourceReference"] = None + self.subject: Optional[str] = None + self.expiration_date: Optional[str] = None + self.certificate_authority: Optional[str] = None self.subject_alternative_names = subject_alternative_names - self.thumbprint = None + self.thumbprint: Optional[str] = None class CacheConfiguration(_serialization.Model): @@ -2173,13 +2234,64 @@ def __init__( self.cache_duration = cache_duration -class CacheExpirationActionParameters(_serialization.Model): +class DeliveryRuleActionParameters(_serialization.Model): + """Defines the parameters for delivery rule actions. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CacheExpirationActionParameters, CacheKeyQueryStringActionParameters, HeaderActionParameters, + OriginGroupOverrideActionParameters, RouteConfigurationOverrideActionParameters, + UrlRedirectActionParameters, UrlRewriteActionParameters, UrlSigningActionParameters + + All required parameters must be populated in order to send to server. + + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType + """ + + _validation = { + "type_name": {"required": True}, + } + + _attribute_map = { + "type_name": {"key": "typeName", "type": "str"}, + } + + _subtype_map = { + "type_name": { + "DeliveryRuleCacheExpirationActionParameters": "CacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters": "CacheKeyQueryStringActionParameters", + "DeliveryRuleHeaderActionParameters": "HeaderActionParameters", + "DeliveryRuleOriginGroupOverrideActionParameters": "OriginGroupOverrideActionParameters", + "DeliveryRuleRouteConfigurationOverrideActionParameters": "RouteConfigurationOverrideActionParameters", + "DeliveryRuleUrlRedirectActionParameters": "UrlRedirectActionParameters", + "DeliveryRuleUrlRewriteActionParameters": "UrlRewriteActionParameters", + "DeliveryRuleUrlSigningActionParameters": "UrlSigningActionParameters", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type_name: Optional[str] = None + + +class CacheExpirationActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the cache expiration action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleCacheExpirationActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CacheExpirationActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar cache_behavior: Caching behavior for the requests. Required. Known values are: "BypassCache", "Override", and "SetIfMissing". :vartype cache_behavior: str or ~azure.mgmt.cdn.models.CacheBehavior @@ -2206,15 +2318,12 @@ class CacheExpirationActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.CacheExpirationActionParametersTypeName"], cache_behavior: Union[str, "_models.CacheBehavior"], cache_type: Union[str, "_models.CacheType"], cache_duration: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleCacheExpirationActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CacheExpirationActionParametersTypeName :keyword cache_behavior: Caching behavior for the requests. Required. Known values are: "BypassCache", "Override", and "SetIfMissing". :paramtype cache_behavior: str or ~azure.mgmt.cdn.models.CacheBehavior @@ -2225,19 +2334,24 @@ def __init__( :paramtype cache_duration: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleCacheExpirationActionParameters" self.cache_behavior = cache_behavior self.cache_type = cache_type self.cache_duration = cache_duration -class CacheKeyQueryStringActionParameters(_serialization.Model): +class CacheKeyQueryStringActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the cache-key query string action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar query_string_behavior: Caching behavior for the requests. Required. Known values are: "Include", "IncludeAll", "Exclude", and "ExcludeAll". :vartype query_string_behavior: str or ~azure.mgmt.cdn.models.QueryStringBehavior @@ -2259,14 +2373,11 @@ class CacheKeyQueryStringActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.CacheKeyQueryStringActionParametersTypeName"], query_string_behavior: Union[str, "_models.QueryStringBehavior"], query_parameters: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParametersTypeName :keyword query_string_behavior: Caching behavior for the requests. Required. Known values are: "Include", "IncludeAll", "Exclude", and "ExcludeAll". :paramtype query_string_behavior: str or ~azure.mgmt.cdn.models.QueryStringBehavior @@ -2274,7 +2385,7 @@ def __init__( :paramtype query_parameters: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" self.query_string_behavior = query_string_behavior self.query_parameters = query_parameters @@ -2346,20 +2457,55 @@ def __init__(self, *, errors: Optional[List["_models.MigrationErrorType"]] = Non :paramtype errors: list[~azure.mgmt.cdn.models.MigrationErrorType] """ super().__init__(**kwargs) - self.id = None - self.type = None - self.can_migrate = None - self.default_sku = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.can_migrate: Optional[bool] = None + self.default_sku: Optional[Union[str, "_models.CanMigrateDefaultSku"]] = None self.errors = errors -class CdnCertificateSourceParameters(_serialization.Model): +class CertificateSourceParameters(_serialization.Model): + """Defines the parameters for certificate source. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CdnCertificateSourceParameters, KeyVaultCertificateSourceParameters + + All required parameters must be populated in order to send to server. + + :ivar type_name: Required. Known values are: "CdnCertificateSourceParameters" and + "KeyVaultCertificateSourceParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.CertificateSourceParametersType + """ + + _validation = { + "type_name": {"required": True}, + } + + _attribute_map = { + "type_name": {"key": "typeName", "type": "str"}, + } + + _subtype_map = { + "type_name": { + "CdnCertificateSourceParameters": "CdnCertificateSourceParameters", + "KeyVaultCertificateSourceParameters": "KeyVaultCertificateSourceParameters", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type_name: Optional[str] = None + + +class CdnCertificateSourceParameters(CertificateSourceParameters): """Defines the parameters for using CDN managed certificate for securing custom domain. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "CdnCertificateSourceParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CdnCertificateSourceParametersTypeName + :ivar type_name: Required. Known values are: "CdnCertificateSourceParameters" and + "KeyVaultCertificateSourceParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.CertificateSourceParametersType :ivar certificate_type: Type of certificate used. Required. Known values are: "Shared" and "Dedicated". :vartype certificate_type: str or ~azure.mgmt.cdn.models.CertificateType @@ -2375,22 +2521,14 @@ class CdnCertificateSourceParameters(_serialization.Model): "certificate_type": {"key": "certificateType", "type": "str"}, } - def __init__( - self, - *, - type_name: Union[str, "_models.CdnCertificateSourceParametersTypeName"], - certificate_type: Union[str, "_models.CertificateType"], - **kwargs: Any - ) -> None: + def __init__(self, *, certificate_type: Union[str, "_models.CertificateType"], **kwargs: Any) -> None: """ - :keyword type_name: Required. "CdnCertificateSourceParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CdnCertificateSourceParametersTypeName :keyword certificate_type: Type of certificate used. Required. Known values are: "Shared" and "Dedicated". :paramtype certificate_type: str or ~azure.mgmt.cdn.models.CertificateType """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "CdnCertificateSourceParameters" self.certificate_type = certificate_type @@ -2528,7 +2666,47 @@ def __init__( self.certificate_source_parameters = certificate_source_parameters -class CdnWebApplicationFirewallPolicy(TrackedResource): # pylint: disable=too-many-instance-attributes +class CdnMigrationToAfdParameters(_serialization.Model): + """Request body for Migrate operation. + + All required parameters must be populated in order to send to server. + + :ivar sku: Sku for the migration. Required. + :vartype sku: ~azure.mgmt.cdn.models.Sku + :ivar migration_endpoint_mappings: A name map between classic CDN endpoints and AFD + Premium/Standard endpoints. + :vartype migration_endpoint_mappings: list[~azure.mgmt.cdn.models.MigrationEndpointMapping] + """ + + _validation = { + "sku": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "migration_endpoint_mappings": {"key": "migrationEndpointMappings", "type": "[MigrationEndpointMapping]"}, + } + + def __init__( + self, + *, + sku: "_models.Sku", + migration_endpoint_mappings: Optional[List["_models.MigrationEndpointMapping"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: Sku for the migration. Required. + :paramtype sku: ~azure.mgmt.cdn.models.Sku + :keyword migration_endpoint_mappings: A name map between classic CDN endpoints and AFD + Premium/Standard endpoints. + :paramtype migration_endpoint_mappings: list[~azure.mgmt.cdn.models.MigrationEndpointMapping] + """ + super().__init__(**kwargs) + self.sku = sku + self.migration_endpoint_mappings = migration_endpoint_mappings + + +class CdnWebApplicationFirewallPolicy(TrackedResource): """Defines web application firewall policy for Azure CDN. Variables are only populated by the server, and will be ignored when sending a request. @@ -2648,10 +2826,10 @@ def __init__( self.rate_limit_rules = rate_limit_rules self.custom_rules = custom_rules self.managed_rules = managed_rules - self.endpoint_links = None + self.endpoint_links: Optional[List["_models.CdnEndpoint"]] = None self.extended_properties = extended_properties - self.provisioning_state = None - self.resource_state = None + self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None + self.resource_state: Optional[Union[str, "_models.PolicyResourceState"]] = None class CdnWebApplicationFirewallPolicyList(_serialization.Model): @@ -2683,7 +2861,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.CdnWebApplicationFirewallPolicy"]] = None self.next_link = next_link @@ -2797,10 +2975,10 @@ class CheckEndpointNameAvailabilityOutput(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name_available = None - self.available_hostname = None - self.reason = None - self.message = None + self.name_available: Optional[bool] = None + self.available_hostname: Optional[str] = None + self.reason: Optional[str] = None + self.message: Optional[str] = None class CheckHostNameAvailabilityInput(_serialization.Model): @@ -2892,9 +3070,9 @@ class CheckNameAvailabilityOutput(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = None + self.name_available: Optional[bool] = None + self.reason: Optional[str] = None + self.message: Optional[str] = None class CidrIpAddress(_serialization.Model): @@ -2925,13 +3103,92 @@ def __init__( self.prefix_length = prefix_length -class ClientPortMatchConditionParameters(_serialization.Model): +class DeliveryRuleConditionParameters(_serialization.Model): + """Defines the parameters for delivery rule match conditions. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ClientPortMatchConditionParameters, CookiesMatchConditionParameters, + HostNameMatchConditionParameters, HttpVersionMatchConditionParameters, + IsDeviceMatchConditionParameters, PostArgsMatchConditionParameters, + QueryStringMatchConditionParameters, RemoteAddressMatchConditionParameters, + RequestBodyMatchConditionParameters, RequestHeaderMatchConditionParameters, + RequestMethodMatchConditionParameters, RequestSchemeMatchConditionParameters, + RequestUriMatchConditionParameters, ServerPortMatchConditionParameters, + SocketAddrMatchConditionParameters, SslProtocolMatchConditionParameters, + UrlFileExtensionMatchConditionParameters, UrlFileNameMatchConditionParameters, + UrlPathMatchConditionParameters + + All required parameters must be populated in order to send to server. + + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType + """ + + _validation = { + "type_name": {"required": True}, + } + + _attribute_map = { + "type_name": {"key": "typeName", "type": "str"}, + } + + _subtype_map = { + "type_name": { + "DeliveryRuleClientPortConditionParameters": "ClientPortMatchConditionParameters", + "DeliveryRuleCookiesConditionParameters": "CookiesMatchConditionParameters", + "DeliveryRuleHostNameConditionParameters": "HostNameMatchConditionParameters", + "DeliveryRuleHttpVersionConditionParameters": "HttpVersionMatchConditionParameters", + "DeliveryRuleIsDeviceConditionParameters": "IsDeviceMatchConditionParameters", + "DeliveryRulePostArgsConditionParameters": "PostArgsMatchConditionParameters", + "DeliveryRuleQueryStringConditionParameters": "QueryStringMatchConditionParameters", + "DeliveryRuleRemoteAddressConditionParameters": "RemoteAddressMatchConditionParameters", + "DeliveryRuleRequestBodyConditionParameters": "RequestBodyMatchConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters": "RequestHeaderMatchConditionParameters", + "DeliveryRuleRequestMethodConditionParameters": "RequestMethodMatchConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters": "RequestSchemeMatchConditionParameters", + "DeliveryRuleRequestUriConditionParameters": "RequestUriMatchConditionParameters", + "DeliveryRuleServerPortConditionParameters": "ServerPortMatchConditionParameters", + "DeliveryRuleSocketAddrConditionParameters": "SocketAddrMatchConditionParameters", + "DeliveryRuleSslProtocolConditionParameters": "SslProtocolMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters": "UrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters": "UrlFileNameMatchConditionParameters", + "DeliveryRuleUrlPathMatchConditionParameters": "UrlPathMatchConditionParameters", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type_name: Optional[str] = None + + +class ClientPortMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for ClientPort match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleClientPortConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.ClientPortMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -2960,7 +3217,6 @@ class ClientPortMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.ClientPortMatchConditionParametersTypeName"], operator: Union[str, "_models.ClientPortOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -2968,8 +3224,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleClientPortConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.ClientPortMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -2982,7 +3236,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleClientPortConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -3216,13 +3470,23 @@ def __init__( self.continent_id = continent_id -class CookiesMatchConditionParameters(_serialization.Model): +class CookiesMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for Cookies match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleCookiesConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CookiesMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar selector: Name of Cookies to be matched. :vartype selector: str :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", @@ -3254,7 +3518,6 @@ class CookiesMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.CookiesMatchConditionParametersTypeName"], operator: Union[str, "_models.CookiesOperator"], selector: Optional[str] = None, negate_condition: bool = False, @@ -3263,8 +3526,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleCookiesConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CookiesMatchConditionParametersTypeName :keyword selector: Name of Cookies to be matched. :paramtype selector: str :keyword operator: Describes operator to be matched. Required. Known values are: "Any", @@ -3279,7 +3540,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleCookiesConditionParameters" self.selector = selector self.operator = operator self.negate_condition = negate_condition @@ -3287,7 +3548,7 @@ def __init__( self.transforms = transforms -class CustomDomain(ProxyResource): # pylint: disable=too-many-instance-attributes +class CustomDomain(ProxyResource): """Friendly domain name mapping to the endpoint hostname that the customer provides for branding purposes, e.g. www.contoso.com. @@ -3374,12 +3635,12 @@ def __init__( """ super().__init__(**kwargs) self.host_name = host_name - self.resource_state = None - self.custom_https_provisioning_state = None - self.custom_https_provisioning_substate = None + self.resource_state: Optional[Union[str, "_models.CustomDomainResourceState"]] = None + self.custom_https_provisioning_state: Optional[Union[str, "_models.CustomHttpsProvisioningState"]] = None + self.custom_https_provisioning_substate: Optional[Union[str, "_models.CustomHttpsProvisioningSubstate"]] = None self.custom_https_parameters = custom_https_parameters self.validation_data = validation_data - self.provisioning_state = None + self.provisioning_state: Optional[Union[str, "_models.CustomHttpsProvisioningState"]] = None class CustomDomainListResult(_serialization.Model): @@ -3409,7 +3670,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.CustomDomain"]] = None self.next_link = next_link @@ -3447,7 +3708,7 @@ class CustomerCertificate(Certificate): :vartype expiration_date: str :ivar secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar secret_version: Certificate version. :vartype secret_version: str @@ -3496,7 +3757,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.cdn.models.SecretType :keyword secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference :keyword secret_version: Certificate version. :paramtype secret_version: str @@ -3508,10 +3769,10 @@ def __init__( super().__init__(type=type, **kwargs) self.secret_source = secret_source self.secret_version = secret_version - self.certificate_authority = None + self.certificate_authority: Optional[str] = None self.use_latest_version = use_latest_version self.subject_alternative_names = subject_alternative_names - self.thumbprint = None + self.thumbprint: Optional[str] = None class CustomerCertificateParameters(SecretParameters): @@ -3526,7 +3787,7 @@ class CustomerCertificateParameters(SecretParameters): :vartype type: str or ~azure.mgmt.cdn.models.SecretType :ivar secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. Required. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar secret_version: Version of the secret to be used. @@ -3578,7 +3839,7 @@ def __init__( """ :keyword secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. Required. :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference :keyword secret_version: Version of the secret to be used. @@ -3593,11 +3854,11 @@ def __init__( self.secret_source = secret_source self.secret_version = secret_version self.use_latest_version = use_latest_version - self.subject = None - self.expiration_date = None - self.certificate_authority = None + self.subject: Optional[str] = None + self.expiration_date: Optional[str] = None + self.certificate_authority: Optional[str] = None self.subject_alternative_names = subject_alternative_names - self.thumbprint = None + self.thumbprint: Optional[str] = None class CustomRule(_serialization.Model): @@ -3732,7 +3993,7 @@ def __init__( self.validation_data = validation_data -class DeepCreatedOrigin(_serialization.Model): # pylint: disable=too-many-instance-attributes +class DeepCreatedOrigin(_serialization.Model): """The main origin of CDN content which is added when creating a CDN endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -3873,7 +4134,7 @@ def __init__( self.private_link_resource_id = private_link_resource_id self.private_link_location = private_link_location self.private_link_approval_message = private_link_approval_message - self.private_endpoint_status = None + self.private_endpoint_status: Optional[Union[str, "_models.PrivateEndpointStatus"]] = None class DeepCreatedOriginGroup(_serialization.Model): @@ -5007,8 +5268,8 @@ class DomainValidationProperties(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.validation_token = None - self.expiration_date = None + self.validation_token: Optional[str] = None + self.expiration_date: Optional[str] = None class EdgeNode(ProxyResource): @@ -5079,11 +5340,11 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.EdgeNode"]] = None self.next_link = next_link -class Endpoint(TrackedResource): # pylint: disable=too-many-instance-attributes +class Endpoint(TrackedResource): """CDN endpoint is the entity within a CDN profile containing configuration information such as origin, protocol, content caching and delivery behavior. The CDN endpoint uses the URL format :code:``.azureedge.net. @@ -5327,12 +5588,12 @@ def __init__( # pylint: disable=too-many-locals self.url_signing_keys = url_signing_keys self.delivery_policy = delivery_policy self.web_application_firewall_policy_link = web_application_firewall_policy_link - self.host_name = None + self.host_name: Optional[str] = None self.origins = origins self.origin_groups = origin_groups - self.custom_domains = None - self.resource_state = None - self.provisioning_state = None + self.custom_domains: Optional[List["_models.DeepCreatedCustomDomain"]] = None + self.resource_state: Optional[Union[str, "_models.EndpointResourceState"]] = None + self.provisioning_state: Optional[Union[str, "_models.EndpointProvisioningState"]] = None class EndpointListResult(_serialization.Model): @@ -5362,11 +5623,11 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Endpoint"]] = None self.next_link = next_link -class EndpointPropertiesUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class EndpointPropertiesUpdateParameters(_serialization.Model): """The JSON object containing endpoint update parameters. :ivar origin_path: A directory path on the origin that CDN can use to retrieve content from, @@ -5538,7 +5799,7 @@ def __init__( self.web_application_firewall_policy_link = web_application_firewall_policy_link -class EndpointProperties(EndpointPropertiesUpdateParameters): # pylint: disable=too-many-instance-attributes +class EndpointProperties(EndpointPropertiesUpdateParameters): """The JSON object that contains the properties required to create an endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5751,12 +6012,12 @@ def __init__( web_application_firewall_policy_link=web_application_firewall_policy_link, **kwargs ) - self.host_name = None + self.host_name: Optional[str] = None self.origins = origins self.origin_groups = origin_groups - self.custom_domains = None - self.resource_state = None - self.provisioning_state = None + self.custom_domains: Optional[List["_models.DeepCreatedCustomDomain"]] = None + self.resource_state: Optional[Union[str, "_models.EndpointResourceState"]] = None + self.provisioning_state: Optional[Union[str, "_models.EndpointProvisioningState"]] = None class EndpointPropertiesUpdateParametersDeliveryPolicy(_serialization.Model): # pylint: disable=name-too-long @@ -5815,7 +6076,7 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin self.id = id -class EndpointUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class EndpointUpdateParameters(_serialization.Model): """Properties required to create or update an endpoint. :ivar tags: Endpoint tags. @@ -6021,8 +6282,8 @@ class ErrorAdditionalInfo(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None - self.info = None + self.type: Optional[str] = None + self.info: Optional[JSON] = None class ErrorDetail(_serialization.Model): @@ -6061,17 +6322,38 @@ class ErrorDetail(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + 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): """Error response indicates Azure Front Door Standard or Azure Front Door Premium or CDN service is not able to process the incoming request. The reason is provided in the error message. + :ivar error: The error detail. + :vartype error: ~azure.mgmt.cdn.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error detail. + :paramtype error: ~azure.mgmt.cdn.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseAutoGenerated(_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.cdn.models.ErrorDetail """ @@ -6142,13 +6424,18 @@ def __init__( self.country_codes = country_codes -class HeaderActionParameters(_serialization.Model): +class HeaderActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the request header action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleHeaderActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.HeaderActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar header_action: Action to perform. Required. Known values are: "Append", "Overwrite", and "Delete". :vartype header_action: str or ~azure.mgmt.cdn.models.HeaderAction @@ -6174,15 +6461,12 @@ class HeaderActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.HeaderActionParametersTypeName"], header_action: Union[str, "_models.HeaderAction"], header_name: str, value: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleHeaderActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.HeaderActionParametersTypeName :keyword header_action: Action to perform. Required. Known values are: "Append", "Overwrite", and "Delete". :paramtype header_action: str or ~azure.mgmt.cdn.models.HeaderAction @@ -6192,7 +6476,7 @@ def __init__( :paramtype value: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleHeaderActionParameters" self.header_action = header_action self.header_name = header_name self.value = value @@ -6255,13 +6539,23 @@ def __init__( self.probe_interval_in_seconds = probe_interval_in_seconds -class HostNameMatchConditionParameters(_serialization.Model): +class HostNameMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for HostName match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleHostNameConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.HostNameMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -6290,7 +6584,6 @@ class HostNameMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.HostNameMatchConditionParametersTypeName"], operator: Union[str, "_models.HostNameOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -6298,8 +6591,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleHostNameConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.HostNameMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -6312,7 +6603,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleHostNameConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -6350,13 +6641,23 @@ def __init__(self, *, begin: Optional[int] = None, end: Optional[int] = None, ** self.end = end -class HttpVersionMatchConditionParameters(_serialization.Model): +class HttpVersionMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for HttpVersion match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleHttpVersionConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.HttpVersionMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.HttpVersionOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -6383,7 +6684,6 @@ class HttpVersionMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.HttpVersionMatchConditionParametersTypeName"], operator: Union[str, "_models.HttpVersionOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -6391,8 +6691,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleHttpVersionConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.HttpVersionMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.HttpVersionOperator :keyword negate_condition: Describes if this is negate condition or not. @@ -6403,7 +6701,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleHttpVersionConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -6449,20 +6747,29 @@ def __init__( self.ipv6_addresses = ipv6_addresses -class IsDeviceMatchConditionParameters(_serialization.Model): +class IsDeviceMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for IsDevice match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleIsDeviceConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.IsDeviceOperator :ivar negate_condition: Describes if this is negate condition or not. :vartype negate_condition: bool :ivar match_values: The match value for the condition of the delivery rule. - :vartype match_values: list[str or - ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersMatchValuesItem] + :vartype match_values: list[str or ~azure.mgmt.cdn.models.IsDeviceMatchValue] :ivar transforms: List of transforms. :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ @@ -6483,41 +6790,38 @@ class IsDeviceMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.IsDeviceMatchConditionParametersTypeName"], operator: Union[str, "_models.IsDeviceOperator"], negate_condition: bool = False, - match_values: Optional[List[Union[str, "_models.IsDeviceMatchConditionParametersMatchValuesItem"]]] = None, + match_values: Optional[List[Union[str, "_models.IsDeviceMatchValue"]]] = None, transforms: Optional[List[Union[str, "_models.Transform"]]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleIsDeviceConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.IsDeviceOperator :keyword negate_condition: Describes if this is negate condition or not. :paramtype negate_condition: bool :keyword match_values: The match value for the condition of the delivery rule. - :paramtype match_values: list[str or - ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersMatchValuesItem] + :paramtype match_values: list[str or ~azure.mgmt.cdn.models.IsDeviceMatchValue] :keyword transforms: List of transforms. :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleIsDeviceConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class KeyVaultCertificateSourceParameters(_serialization.Model): +class KeyVaultCertificateSourceParameters(CertificateSourceParameters): """Describes the parameters for using a user's KeyVault certificate for securing custom domain. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "KeyVaultCertificateSourceParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParametersTypeName + :ivar type_name: Required. Known values are: "CdnCertificateSourceParameters" and + "KeyVaultCertificateSourceParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.CertificateSourceParametersType :ivar subscription_id: Subscription Id of the user's Key Vault containing the SSL certificate. Required. :vartype subscription_id: str @@ -6563,7 +6867,6 @@ class KeyVaultCertificateSourceParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.KeyVaultCertificateSourceParametersTypeName"], subscription_id: str, resource_group_name: str, vault_name: str, @@ -6574,8 +6877,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "KeyVaultCertificateSourceParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParametersTypeName :keyword subscription_id: Subscription Id of the user's Key Vault containing the SSL certificate. Required. :paramtype subscription_id: str @@ -6597,7 +6898,7 @@ def __init__( :paramtype delete_rule: str or ~azure.mgmt.cdn.models.DeleteRule """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "KeyVaultCertificateSourceParameters" self.subscription_id = subscription_id self.resource_group_name = resource_group_name self.vault_name = vault_name @@ -6613,7 +6914,7 @@ class KeyVaultSigningKeyParameters(_serialization.Model): All required parameters must be populated in order to send to server. :ivar type_name: Required. "KeyVaultSigningKeyParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersTypeName + :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersType :ivar subscription_id: Subscription Id of the user's Key Vault containing the secret. Required. :vartype subscription_id: str :ivar resource_group_name: Resource group of the user's Key Vault containing the secret. @@ -6648,7 +6949,7 @@ class KeyVaultSigningKeyParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.KeyVaultSigningKeyParametersTypeName"], + type_name: Union[str, "_models.KeyVaultSigningKeyParametersType"], subscription_id: str, resource_group_name: str, vault_name: str, @@ -6658,7 +6959,7 @@ def __init__( ) -> None: """ :keyword type_name: Required. "KeyVaultSigningKeyParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersTypeName + :paramtype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersType :keyword subscription_id: Subscription Id of the user's Key Vault containing the secret. Required. :paramtype subscription_id: str @@ -6845,8 +7146,8 @@ def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "ManagedCertificate" - self.subject = None - self.expiration_date = None + self.subject: Optional[str] = None + self.expiration_date: Optional[str] = None class ManagedRuleDefinition(_serialization.Model): @@ -6873,8 +7174,8 @@ class ManagedRuleDefinition(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.rule_id = None - self.description = None + self.rule_id: Optional[str] = None + self.description: Optional[str] = None class ManagedRuleGroupDefinition(_serialization.Model): @@ -6905,9 +7206,9 @@ class ManagedRuleGroupDefinition(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.rule_group_name = None - self.description = None - self.rules = None + self.rule_group_name: Optional[str] = None + self.description: Optional[str] = None + self.rules: Optional[List["_models.ManagedRuleDefinition"]] = None class ManagedRuleGroupOverride(_serialization.Model): @@ -7110,10 +7411,10 @@ def __init__(self, *, sku: Optional["_models.Sku"] = None, **kwargs: Any) -> Non """ super().__init__(**kwargs) self.sku = sku - self.provisioning_state = None - self.rule_set_type = None - self.rule_set_version = None - self.rule_groups = None + self.provisioning_state: Optional[str] = None + self.rule_set_type: Optional[str] = None + self.rule_set_version: Optional[str] = None + self.rule_groups: Optional[List["_models.ManagedRuleGroupDefinition"]] = None class ManagedRuleSetDefinitionList(_serialization.Model): @@ -7142,7 +7443,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.ManagedRuleSetDefinition"]] = None self.next_link = next_link @@ -7185,7 +7486,7 @@ class ManagedServiceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.cdn.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.cdn.models.UserAssignedIdentity] """ @@ -7217,13 +7518,13 @@ def __init__( :paramtype type: str or ~azure.mgmt.cdn.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.cdn.models.UserAssignedIdentity] """ super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None self.type = type self.user_assigned_identities = user_assigned_identities @@ -7332,7 +7633,7 @@ def __init__(self, *, time_grain: Optional[str] = None, blob_duration: Optional[ self.blob_duration = blob_duration -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -7582,9 +7883,39 @@ class MigrateResult(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.id = None - self.type = None - self.migrated_profile_resource_id = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.migrated_profile_resource_id: Optional["_models.ResourceReference"] = None + + +class MigrationEndpointMapping(_serialization.Model): + """CDN Endpoint Mapping. + + :ivar migrated_from: Name of the classic CDN profile endpoint. + :vartype migrated_from: str + :ivar migrated_to: Name of the newly created migrated Azure Frontdoor Standard/Premium profile + endpoint. This name will replace the name of the classic CDN endpoint resource. + :vartype migrated_to: str + """ + + _attribute_map = { + "migrated_from": {"key": "migratedFrom", "type": "str"}, + "migrated_to": {"key": "migratedTo", "type": "str"}, + } + + def __init__( + self, *, migrated_from: Optional[str] = None, migrated_to: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword migrated_from: Name of the classic CDN profile endpoint. + :paramtype migrated_from: str + :keyword migrated_to: Name of the newly created migrated Azure Frontdoor Standard/Premium + profile endpoint. This name will replace the name of the classic CDN endpoint resource. + :paramtype migrated_to: str + """ + super().__init__(**kwargs) + self.migrated_from = migrated_from + self.migrated_to = migrated_to class MigrationErrorType(_serialization.Model): @@ -7620,10 +7951,10 @@ class MigrationErrorType(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.resource_name = None - self.error_message = None - self.next_steps = None + self.code: Optional[str] = None + self.resource_name: Optional[str] = None + self.error_message: Optional[str] = None + self.next_steps: Optional[str] = None class MigrationParameters(_serialization.Model): @@ -7768,10 +8099,10 @@ def __init__( :paramtype service_specification: ~azure.mgmt.cdn.models.ServiceSpecification """ super().__init__(**kwargs) - self.name = None + self.name: Optional[str] = None self.is_data_action = is_data_action self.display = display - self.origin = None + self.origin: Optional[str] = None self.service_specification = service_specification @@ -7807,10 +8138,10 @@ class OperationDisplay(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None + self.provider: Optional[str] = None + self.resource: Optional[str] = None + self.operation: Optional[str] = None + self.description: Optional[str] = None class OperationsListResult(_serialization.Model): @@ -7842,7 +8173,7 @@ def __init__( self.next_link = next_link -class Origin(ProxyResource): # pylint: disable=too-many-instance-attributes +class Origin(ProxyResource): """CDN origin is the source of the content being delivered via CDN. When the edge nodes represented by an endpoint do not have the requested content cached, they attempt to fetch it from one or more of the configured origins. @@ -7999,9 +8330,9 @@ def __init__( self.private_link_resource_id = private_link_resource_id self.private_link_location = private_link_location self.private_link_approval_message = private_link_approval_message - self.resource_state = None - self.provisioning_state = None - self.private_endpoint_status = None + self.resource_state: Optional[Union[str, "_models.OriginResourceState"]] = None + self.provisioning_state: Optional[Union[str, "_models.OriginProvisioningState"]] = None + self.private_endpoint_status: Optional[Union[str, "_models.PrivateEndpointStatus"]] = None class OriginGroup(ProxyResource): @@ -8103,8 +8434,8 @@ def __init__( traffic_restoration_time_to_healed_or_new_endpoints_in_minutes ) self.response_based_origin_error_detection_settings = response_based_origin_error_detection_settings - self.resource_state = None - self.provisioning_state = None + self.resource_state: Optional[Union[str, "_models.OriginGroupResourceState"]] = None + self.provisioning_state: Optional[Union[str, "_models.OriginGroupProvisioningState"]] = None class OriginGroupListResult(_serialization.Model): @@ -8134,7 +8465,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.OriginGroup"]] = None self.next_link = next_link @@ -8208,13 +8539,18 @@ def __init__(self, *, parameters: "_models.OriginGroupOverrideActionParameters", self.parameters = parameters -class OriginGroupOverrideActionParameters(_serialization.Model): +class OriginGroupOverrideActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the origin group override action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleOriginGroupOverrideActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.OriginGroupOverrideActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar origin_group: defines the OriginGroup that would override the DefaultOriginGroup. Required. :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference @@ -8230,22 +8566,14 @@ class OriginGroupOverrideActionParameters(_serialization.Model): "origin_group": {"key": "originGroup", "type": "ResourceReference"}, } - def __init__( - self, - *, - type_name: Union[str, "_models.OriginGroupOverrideActionParametersTypeName"], - origin_group: "_models.ResourceReference", - **kwargs: Any - ) -> None: + def __init__(self, *, origin_group: "_models.ResourceReference", **kwargs: Any) -> None: """ - :keyword type_name: Required. "DeliveryRuleOriginGroupOverrideActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.OriginGroupOverrideActionParametersTypeName :keyword origin_group: defines the OriginGroup that would override the DefaultOriginGroup. Required. :paramtype origin_group: ~azure.mgmt.cdn.models.ResourceReference """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleOriginGroupOverrideActionParameters" self.origin_group = origin_group @@ -8403,8 +8731,8 @@ def __init__( response_based_origin_error_detection_settings=response_based_origin_error_detection_settings, **kwargs ) - self.resource_state = None - self.provisioning_state = None + self.resource_state: Optional[Union[str, "_models.OriginGroupResourceState"]] = None + self.provisioning_state: Optional[Union[str, "_models.OriginGroupProvisioningState"]] = None class OriginGroupUpdateParameters(_serialization.Model): @@ -8506,11 +8834,11 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Origin"]] = None self.next_link = next_link -class OriginUpdatePropertiesParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class OriginUpdatePropertiesParameters(_serialization.Model): """The JSON object that contains the properties of the origin. :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses @@ -8634,7 +8962,7 @@ def __init__( self.private_link_approval_message = private_link_approval_message -class OriginProperties(OriginUpdatePropertiesParameters): # pylint: disable=too-many-instance-attributes +class OriginProperties(OriginUpdatePropertiesParameters): """The JSON object that contains the properties of the origin. Variables are only populated by the server, and will be ignored when sending a request. @@ -8775,12 +9103,12 @@ def __init__( private_link_approval_message=private_link_approval_message, **kwargs ) - self.resource_state = None - self.provisioning_state = None - self.private_endpoint_status = None + self.resource_state: Optional[Union[str, "_models.OriginResourceState"]] = None + self.provisioning_state: Optional[Union[str, "_models.OriginProvisioningState"]] = None + self.private_endpoint_status: Optional[Union[str, "_models.PrivateEndpointStatus"]] = None -class OriginUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class OriginUpdateParameters(_serialization.Model): """Origin properties needed for origin update. :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses @@ -8979,13 +9307,23 @@ def __init__( self.default_custom_block_response_body = default_custom_block_response_body -class PostArgsMatchConditionParameters(_serialization.Model): +class PostArgsMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for PostArgs match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRulePostArgsConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.PostArgsMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar selector: Name of PostArg to be matched. :vartype selector: str :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", @@ -9017,7 +9355,6 @@ class PostArgsMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.PostArgsMatchConditionParametersTypeName"], operator: Union[str, "_models.PostArgsOperator"], selector: Optional[str] = None, negate_condition: bool = False, @@ -9026,8 +9363,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRulePostArgsConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.PostArgsMatchConditionParametersTypeName :keyword selector: Name of PostArg to be matched. :paramtype selector: str :keyword operator: Describes operator to be matched. Required. Known values are: "Any", @@ -9042,7 +9377,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRulePostArgsConditionParameters" self.selector = selector self.operator = operator self.negate_condition = negate_condition @@ -9050,7 +9385,7 @@ def __init__( self.transforms = transforms -class Profile(TrackedResource): # pylint: disable=too-many-instance-attributes +class Profile(TrackedResource): """A profile is a logical grouping of endpoints that share the same settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -9159,12 +9494,12 @@ def __init__( """ super().__init__(location=location, tags=tags, **kwargs) self.sku = sku - self.kind = None + self.kind: Optional[str] = None self.identity = identity - self.resource_state = None - self.provisioning_state = None - self.extended_properties = None - self.front_door_id = None + self.resource_state: Optional[Union[str, "_models.ProfileResourceState"]] = None + self.provisioning_state: Optional[Union[str, "_models.ProfileProvisioningState"]] = None + self.extended_properties: Optional[Dict[str, str]] = None + self.front_door_id: Optional[str] = None self.origin_response_timeout_seconds = origin_response_timeout_seconds self.log_scrubbing = log_scrubbing @@ -9231,7 +9566,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Profile"]] = None self.next_link = next_link @@ -9441,13 +9776,23 @@ def __init__(self, *, content_paths: List[str], **kwargs: Any) -> None: self.content_paths = content_paths -class QueryStringMatchConditionParameters(_serialization.Model): +class QueryStringMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for QueryString match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleQueryStringConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.QueryStringMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9476,7 +9821,6 @@ class QueryStringMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.QueryStringMatchConditionParametersTypeName"], operator: Union[str, "_models.QueryStringOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -9484,8 +9828,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleQueryStringConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.QueryStringMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9498,7 +9840,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleQueryStringConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -9756,13 +10098,23 @@ def __init__(self, *, rules: Optional[List["_models.RateLimitRule"]] = None, **k self.rules = rules -class RemoteAddressMatchConditionParameters(_serialization.Model): +class RemoteAddressMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RemoteAddress match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRemoteAddressConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", and "GeoMatch". :vartype operator: str or ~azure.mgmt.cdn.models.RemoteAddressOperator @@ -9792,7 +10144,6 @@ class RemoteAddressMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RemoteAddressMatchConditionParametersTypeName"], operator: Union[str, "_models.RemoteAddressOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -9800,9 +10151,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRemoteAddressConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", and "GeoMatch". :paramtype operator: str or ~azure.mgmt.cdn.models.RemoteAddressOperator @@ -9816,20 +10164,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRemoteAddressConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class RequestBodyMatchConditionParameters(_serialization.Model): +class RequestBodyMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestBody match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestBodyConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestBodyMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9858,7 +10216,6 @@ class RequestBodyMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestBodyMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestBodyOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -9866,8 +10223,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestBodyConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.RequestBodyMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9880,20 +10235,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestBodyConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class RequestHeaderMatchConditionParameters(_serialization.Model): +class RequestHeaderMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestHeader match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestHeaderConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar selector: Name of Header to be matched. :vartype selector: str :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", @@ -9925,7 +10290,6 @@ class RequestHeaderMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestHeaderMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestHeaderOperator"], selector: Optional[str] = None, negate_condition: bool = False, @@ -9934,9 +10298,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestHeaderConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParametersTypeName :keyword selector: Name of Header to be matched. :paramtype selector: str :keyword operator: Describes operator to be matched. Required. Known values are: "Any", @@ -9951,7 +10312,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestHeaderConditionParameters" self.selector = selector self.operator = operator self.negate_condition = negate_condition @@ -9959,13 +10320,23 @@ def __init__( self.transforms = transforms -class RequestMethodMatchConditionParameters(_serialization.Model): +class RequestMethodMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestMethod match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestMethodConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.RequestMethodOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -9973,8 +10344,7 @@ class RequestMethodMatchConditionParameters(_serialization.Model): :ivar transforms: List of transforms. :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :ivar match_values: The match value for the condition of the delivery rule. - :vartype match_values: list[str or - ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersMatchValuesItem] + :vartype match_values: list[str or ~azure.mgmt.cdn.models.RequestMethodMatchValue] """ _validation = { @@ -9993,17 +10363,13 @@ class RequestMethodMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestMethodMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestMethodOperator"], negate_condition: bool = False, transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - match_values: Optional[List[Union[str, "_models.RequestMethodMatchConditionParametersMatchValuesItem"]]] = None, + match_values: Optional[List[Union[str, "_models.RequestMethodMatchValue"]]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestMethodConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.RequestMethodOperator :keyword negate_condition: Describes if this is negate condition or not. @@ -10011,24 +10377,33 @@ def __init__( :keyword transforms: List of transforms. :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :keyword match_values: The match value for the condition of the delivery rule. - :paramtype match_values: list[str or - ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersMatchValuesItem] + :paramtype match_values: list[str or ~azure.mgmt.cdn.models.RequestMethodMatchValue] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestMethodConditionParameters" self.operator = operator self.negate_condition = negate_condition self.transforms = transforms self.match_values = match_values -class RequestSchemeMatchConditionParameters(_serialization.Model): +class RequestSchemeMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestScheme match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestSchemeConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -10036,8 +10411,7 @@ class RequestSchemeMatchConditionParameters(_serialization.Model): :ivar transforms: List of transforms. :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :ivar match_values: The match value for the condition of the delivery rule. - :vartype match_values: list[str or - ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersMatchValuesItem] + :vartype match_values: list[str or ~azure.mgmt.cdn.models.RequestSchemeMatchValue] """ _validation = { @@ -10056,17 +10430,13 @@ class RequestSchemeMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestSchemeMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestSchemeMatchConditionParametersOperator"], negate_condition: bool = False, transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - match_values: Optional[List[Union[str, "_models.RequestSchemeMatchConditionParametersMatchValuesItem"]]] = None, + match_values: Optional[List[Union[str, "_models.RequestSchemeMatchValue"]]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestSchemeConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersOperator @@ -10075,24 +10445,33 @@ def __init__( :keyword transforms: List of transforms. :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :keyword match_values: The match value for the condition of the delivery rule. - :paramtype match_values: list[str or - ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersMatchValuesItem] + :paramtype match_values: list[str or ~azure.mgmt.cdn.models.RequestSchemeMatchValue] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestSchemeConditionParameters" self.operator = operator self.negate_condition = negate_condition self.transforms = transforms self.match_values = match_values -class RequestUriMatchConditionParameters(_serialization.Model): +class RequestUriMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestUri match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestUriConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestUriMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -10121,7 +10500,6 @@ class RequestUriMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestUriMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestUriOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -10129,8 +10507,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestUriConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.RequestUriMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -10143,7 +10519,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestUriConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -10374,10 +10750,10 @@ class ResourceUsage(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.resource_type = None - self.unit = None - self.current_value = None - self.limit = None + self.resource_type: Optional[str] = None + self.unit: Optional[Union[str, "_models.ResourceUsageUnit"]] = None + self.current_value: Optional[int] = None + self.limit: Optional[int] = None class ResourceUsageListResult(_serialization.Model): @@ -10406,7 +10782,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.ResourceUsage"]] = None self.next_link = next_link @@ -10467,7 +10843,7 @@ def __init__( self.http_error_ranges = http_error_ranges -class Route(ProxyResource): # pylint: disable=too-many-instance-attributes +class Route(ProxyResource): """Friendly Routes name mapping to the any Routes or secret related information. Variables are only populated by the server, and will be ignored when sending a request. @@ -10598,7 +10974,7 @@ def __init__( :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState """ super().__init__(**kwargs) - self.endpoint_name = None + self.endpoint_name: Optional[str] = None self.custom_domains = custom_domains self.origin_group = origin_group self.origin_path = origin_path @@ -10610,18 +10986,22 @@ def __init__( self.link_to_default_domain = link_to_default_domain self.https_redirect = https_redirect self.enabled_state = enabled_state - self.provisioning_state = None - self.deployment_status = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None -class RouteConfigurationOverrideActionParameters(_serialization.Model): # pylint: disable=name-too-long +class RouteConfigurationOverrideActionParameters(DeliveryRuleActionParameters): # pylint: disable=name-too-long """Defines the parameters for the route configuration override action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRouteConfigurationOverrideActionParameters" - :vartype type_name: str or - ~azure.mgmt.cdn.models.RouteConfigurationOverrideActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar origin_group_override: A reference to the origin group override configuration. Leave empty to use the default origin group on route. :vartype origin_group_override: ~azure.mgmt.cdn.models.OriginGroupOverride @@ -10643,15 +11023,11 @@ class RouteConfigurationOverrideActionParameters(_serialization.Model): # pylin def __init__( self, *, - type_name: Union[str, "_models.RouteConfigurationOverrideActionParametersTypeName"], origin_group_override: Optional["_models.OriginGroupOverride"] = None, cache_configuration: Optional["_models.CacheConfiguration"] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRouteConfigurationOverrideActionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RouteConfigurationOverrideActionParametersTypeName :keyword origin_group_override: A reference to the origin group override configuration. Leave empty to use the default origin group on route. :paramtype origin_group_override: ~azure.mgmt.cdn.models.OriginGroupOverride @@ -10660,7 +11036,7 @@ def __init__( :paramtype cache_configuration: ~azure.mgmt.cdn.models.CacheConfiguration """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRouteConfigurationOverrideActionParameters" self.origin_group_override = origin_group_override self.cache_configuration = cache_configuration @@ -10692,11 +11068,11 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Route"]] = None self.next_link = next_link -class RouteUpdatePropertiesParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class RouteUpdatePropertiesParameters(_serialization.Model): """The JSON object that contains the properties of the domain to create. Variables are only populated by the server, and will be ignored when sending a request. @@ -10801,7 +11177,7 @@ def __init__( :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState """ super().__init__(**kwargs) - self.endpoint_name = None + self.endpoint_name: Optional[str] = None self.custom_domains = custom_domains self.origin_group = origin_group self.origin_path = origin_path @@ -10815,9 +11191,7 @@ def __init__( self.enabled_state = enabled_state -class RouteProperties( - RouteUpdatePropertiesParameters, AFDStateProperties -): # pylint: disable=too-many-instance-attributes +class RouteProperties(RouteUpdatePropertiesParameters, AFDStateProperties): """The JSON object that contains the properties of the Routes to create. Variables are only populated by the server, and will be ignored when sending a request. @@ -10945,9 +11319,9 @@ def __init__( enabled_state=enabled_state, **kwargs ) - self.provisioning_state = None - self.deployment_status = None - self.endpoint_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.endpoint_name: Optional[str] = None self.custom_domains = custom_domains self.origin_group = origin_group self.origin_path = origin_path @@ -10961,7 +11335,7 @@ def __init__( self.enabled_state = enabled_state -class RouteUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes +class RouteUpdateParameters(_serialization.Model): """The domain JSON object required for domain creation or update. Variables are only populated by the server, and will be ignored when sending a request. @@ -11066,7 +11440,7 @@ def __init__( :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState """ super().__init__(**kwargs) - self.endpoint_name = None + self.endpoint_name: Optional[str] = None self.custom_domains = custom_domains self.origin_group = origin_group self.origin_path = origin_path @@ -11080,7 +11454,7 @@ def __init__( self.enabled_state = enabled_state -class Rule(ProxyResource): # pylint: disable=too-many-instance-attributes +class Rule(ProxyResource): """Friendly Rules name mapping to the any Rules or secret related information. Variables are only populated by the server, and will be ignored when sending a request. @@ -11107,7 +11481,7 @@ class Rule(ProxyResource): # pylint: disable=too-many-instance-attributes :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", "Updating", "Deleting", and "Creating". @@ -11163,17 +11537,17 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) - self.rule_set_name = None + self.rule_set_name: Optional[str] = None self.order = order self.conditions = conditions self.actions = actions self.match_processing_behavior = match_processing_behavior - self.provisioning_state = None - self.deployment_status = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None class RuleListResult(_serialization.Model): @@ -11203,7 +11577,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Rule"]] = None self.next_link = next_link @@ -11226,7 +11600,7 @@ class RuleUpdatePropertiesParameters(_serialization.Model): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11264,11 +11638,11 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) - self.rule_set_name = None + self.rule_set_name: Optional[str] = None self.order = order self.conditions = conditions self.actions = actions @@ -11300,7 +11674,7 @@ class RuleProperties(RuleUpdatePropertiesParameters, AFDStateProperties): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11342,7 +11716,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__( @@ -11352,9 +11726,9 @@ def __init__( match_processing_behavior=match_processing_behavior, **kwargs ) - self.provisioning_state = None - self.deployment_status = None - self.rule_set_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.rule_set_name: Optional[str] = None self.order = order self.conditions = conditions self.actions = actions @@ -11407,9 +11781,9 @@ class RuleSet(ProxyResource): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.profile_name: Optional[str] = None class RuleSetListResult(_serialization.Model): @@ -11439,7 +11813,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.RuleSet"]] = None self.next_link = next_link @@ -11473,7 +11847,7 @@ class RuleSetProperties(AFDStateProperties): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None class RuleUpdateParameters(_serialization.Model): @@ -11495,7 +11869,7 @@ class RuleUpdateParameters(_serialization.Model): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11533,11 +11907,11 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) - self.rule_set_name = None + self.rule_set_name: Optional[str] = None self.order = order self.conditions = conditions self.actions = actions @@ -11596,9 +11970,9 @@ def __init__(self, *, parameters: Optional["_models.SecretParameters"] = None, * :paramtype parameters: ~azure.mgmt.cdn.models.SecretParameters """ super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.profile_name: Optional[str] = None self.parameters = parameters @@ -11629,7 +12003,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Secret"]] = None self.next_link = next_link @@ -11669,7 +12043,7 @@ def __init__(self, *, parameters: Optional["_models.SecretParameters"] = None, * :paramtype parameters: ~azure.mgmt.cdn.models.SecretParameters """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.parameters = parameters @@ -11727,9 +12101,9 @@ def __init__( :paramtype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters """ super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = None + self.provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = None + self.deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = None + self.profile_name: Optional[str] = None self.parameters = parameters @@ -11760,7 +12134,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.SecurityPolicy"]] = None self.next_link = next_link @@ -11802,7 +12176,7 @@ def __init__( :paramtype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters """ super().__init__(**kwargs) - self.profile_name = None + self.profile_name: Optional[str] = None self.parameters = parameters @@ -11934,13 +12308,23 @@ def __init__( self.associations = associations -class ServerPortMatchConditionParameters(_serialization.Model): +class ServerPortMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for ServerPort match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleServerPortConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.ServerPortMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -11969,7 +12353,6 @@ class ServerPortMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.ServerPortMatchConditionParametersTypeName"], operator: Union[str, "_models.ServerPortOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -11977,8 +12360,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleServerPortConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.ServerPortMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -11991,7 +12372,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleServerPortConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -12138,13 +12519,23 @@ def __init__(self, *, name: Optional[Union[str, "_models.SkuName"]] = None, **kw self.name = name -class SocketAddrMatchConditionParameters(_serialization.Model): +class SocketAddrMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for SocketAddress match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleSocketAddrConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.SocketAddrMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any" and "IPMatch". :vartype operator: str or ~azure.mgmt.cdn.models.SocketAddrOperator @@ -12172,7 +12563,6 @@ class SocketAddrMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.SocketAddrMatchConditionParametersTypeName"], operator: Union[str, "_models.SocketAddrOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12180,8 +12570,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleSocketAddrConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.SocketAddrMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any" and "IPMatch". :paramtype operator: str or ~azure.mgmt.cdn.models.SocketAddrOperator @@ -12193,20 +12581,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleSocketAddrConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class SslProtocolMatchConditionParameters(_serialization.Model): +class SslProtocolMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for SslProtocol match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleSslProtocolConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.SslProtocolMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.SslProtocolOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -12233,7 +12631,6 @@ class SslProtocolMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.SslProtocolMatchConditionParametersTypeName"], operator: Union[str, "_models.SslProtocolOperator"], negate_condition: bool = False, match_values: Optional[List[Union[str, "_models.SslProtocol"]]] = None, @@ -12241,8 +12638,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleSslProtocolConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.SslProtocolMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.SslProtocolOperator :keyword negate_condition: Describes if this is negate condition or not. @@ -12253,7 +12648,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleSslProtocolConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -12280,7 +12675,7 @@ class SsoUri(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.sso_uri_value = None + self.sso_uri_value: Optional[str] = None class SupportedOptimizationTypesListResult(_serialization.Model): @@ -12303,7 +12698,7 @@ class SupportedOptimizationTypesListResult(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.supported_optimization_types = None + self.supported_optimization_types: Optional[List[Union[str, "_models.OptimizationType"]]] = None class SystemData(_serialization.Model): @@ -12370,14 +12765,23 @@ def __init__( self.last_modified_at = last_modified_at -class UrlFileExtensionMatchConditionParameters(_serialization.Model): +class UrlFileExtensionMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for UrlFileExtension match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlFileExtensionMatchConditionParameters" - :vartype type_name: str or - ~azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12406,7 +12810,6 @@ class UrlFileExtensionMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlFileExtensionMatchConditionParametersTypeName"], operator: Union[str, "_models.UrlFileExtensionOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12414,9 +12817,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlFileExtensionMatchConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12429,20 +12829,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlFileExtensionMatchConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class UrlFileNameMatchConditionParameters(_serialization.Model): +class UrlFileNameMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for UrlFilename match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlFilenameConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12471,7 +12881,6 @@ class UrlFileNameMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlFileNameMatchConditionParametersTypeName"], operator: Union[str, "_models.UrlFileNameOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12479,8 +12888,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlFilenameConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12493,20 +12900,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlFilenameConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class UrlPathMatchConditionParameters(_serialization.Model): +class UrlPathMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for UrlPath match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlPathMatchConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlPathMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", "Wildcard", and "RegEx". @@ -12535,7 +12952,6 @@ class UrlPathMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlPathMatchConditionParametersTypeName"], operator: Union[str, "_models.UrlPathOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12543,8 +12959,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlPathMatchConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlPathMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", "Wildcard", and "RegEx". @@ -12557,7 +12971,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlPathMatchConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -12598,13 +13012,18 @@ def __init__(self, *, parameters: "_models.UrlRedirectActionParameters", **kwarg self.parameters = parameters -class UrlRedirectActionParameters(_serialization.Model): +class UrlRedirectActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the url redirect action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlRedirectActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlRedirectActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar redirect_type: The redirect type the rule will use when redirecting traffic. Required. Known values are: "Moved", "Found", "TemporaryRedirect", and "PermanentRedirect". :vartype redirect_type: str or ~azure.mgmt.cdn.models.RedirectType @@ -12619,7 +13038,7 @@ class UrlRedirectActionParameters(_serialization.Model): :vartype custom_hostname: str :ivar custom_query_string: The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the incoming query - string. Query string must be in :code:``=:code:`` format. ? and & will be added + string. Query string must be in :code:``=\\ :code:`` format. ? and & will be added automatically so do not include them. :vartype custom_query_string: str :ivar custom_fragment: Fragment to add to the redirect URL. Fragment is the part of the URL @@ -12645,7 +13064,6 @@ class UrlRedirectActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlRedirectActionParametersTypeName"], redirect_type: Union[str, "_models.RedirectType"], destination_protocol: Optional[Union[str, "_models.DestinationProtocol"]] = None, custom_path: Optional[str] = None, @@ -12655,8 +13073,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlRedirectActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlRedirectActionParametersTypeName :keyword redirect_type: The redirect type the rule will use when redirecting traffic. Required. Known values are: "Moved", "Found", "TemporaryRedirect", and "PermanentRedirect". :paramtype redirect_type: str or ~azure.mgmt.cdn.models.RedirectType @@ -12671,7 +13087,7 @@ def __init__( :paramtype custom_hostname: str :keyword custom_query_string: The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the - incoming query string. Query string must be in :code:``=:code:`` format. ? and & + incoming query string. Query string must be in :code:``=\\ :code:`` format. ? and & will be added automatically so do not include them. :paramtype custom_query_string: str :keyword custom_fragment: Fragment to add to the redirect URL. Fragment is the part of the URL @@ -12679,7 +13095,7 @@ def __init__( :paramtype custom_fragment: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlRedirectActionParameters" self.redirect_type = redirect_type self.destination_protocol = destination_protocol self.custom_path = custom_path @@ -12722,13 +13138,18 @@ def __init__(self, *, parameters: "_models.UrlRewriteActionParameters", **kwargs self.parameters = parameters -class UrlRewriteActionParameters(_serialization.Model): +class UrlRewriteActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the url rewrite action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlRewriteActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlRewriteActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar source_pattern: define a request URI pattern that identifies the type of requests that may be rewritten. If value is blank, all strings are matched. Required. :vartype source_pattern: str @@ -12753,17 +13174,9 @@ class UrlRewriteActionParameters(_serialization.Model): } def __init__( - self, - *, - type_name: Union[str, "_models.UrlRewriteActionParametersTypeName"], - source_pattern: str, - destination: str, - preserve_unmatched_path: Optional[bool] = None, - **kwargs: Any + self, *, source_pattern: str, destination: str, preserve_unmatched_path: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlRewriteActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlRewriteActionParametersTypeName :keyword source_pattern: define a request URI pattern that identifies the type of requests that may be rewritten. If value is blank, all strings are matched. Required. :paramtype source_pattern: str @@ -12774,7 +13187,7 @@ def __init__( :paramtype preserve_unmatched_path: bool """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlRewriteActionParameters" self.source_pattern = source_pattern self.destination = destination self.preserve_unmatched_path = preserve_unmatched_path @@ -12814,13 +13227,18 @@ def __init__(self, *, parameters: "_models.UrlSigningActionParameters", **kwargs self.parameters = parameters -class UrlSigningActionParameters(_serialization.Model): +class UrlSigningActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the Url Signing action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlSigningActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlSigningActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar algorithm: Algorithm to use for URL signing. "SHA256" :vartype algorithm: str or ~azure.mgmt.cdn.models.Algorithm :ivar parameter_name_override: Defines which query string parameters in the url to be @@ -12841,14 +13259,11 @@ class UrlSigningActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlSigningActionParametersTypeName"], algorithm: Optional[Union[str, "_models.Algorithm"]] = None, parameter_name_override: Optional[List["_models.UrlSigningParamIdentifier"]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlSigningActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlSigningActionParametersTypeName :keyword algorithm: Algorithm to use for URL signing. "SHA256" :paramtype algorithm: str or ~azure.mgmt.cdn.models.Algorithm :keyword parameter_name_override: Defines which query string parameters in the url to be @@ -12856,7 +13271,7 @@ def __init__( :paramtype parameter_name_override: list[~azure.mgmt.cdn.models.UrlSigningParamIdentifier] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlSigningActionParameters" self.algorithm = algorithm self.parameter_name_override = parameter_name_override @@ -12913,10 +13328,10 @@ class UrlSigningKeyParameters(SecretParameters): :vartype key_id: str :ivar secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. Required. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :ivar secret_version: Version of the secret to be used. + :ivar secret_version: Version of the secret to be used. Required. :vartype secret_version: str """ @@ -12924,6 +13339,7 @@ class UrlSigningKeyParameters(SecretParameters): "type": {"required": True}, "key_id": {"required": True}, "secret_source": {"required": True}, + "secret_version": {"required": True}, } _attribute_map = { @@ -12934,12 +13350,7 @@ class UrlSigningKeyParameters(SecretParameters): } def __init__( - self, - *, - key_id: str, - secret_source: "_models.ResourceReference", - secret_version: Optional[str] = None, - **kwargs: Any + self, *, key_id: str, secret_source: "_models.ResourceReference", secret_version: str, **kwargs: Any ) -> None: """ :keyword key_id: Defines the customer defined key Id. This id will exist in the incoming @@ -12947,10 +13358,10 @@ def __init__( :paramtype key_id: str :keyword secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. Required. :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :keyword secret_version: Version of the secret to be used. + :keyword secret_version: Version of the secret to be used. Required. :paramtype secret_version: str """ super().__init__(**kwargs) @@ -13052,7 +13463,7 @@ def __init__( :paramtype name: ~azure.mgmt.cdn.models.UsageName """ super().__init__(**kwargs) - self.id = None + self.id: Optional[str] = None self.unit = unit self.current_value = current_value self.limit = limit @@ -13137,8 +13548,8 @@ class UserAssignedIdentity(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.principal_id = None - self.client_id = None + self.principal_id: Optional[str] = None + self.client_id: Optional[str] = None class UserManagedHttpsParameters(CustomDomainHttpsParameters): @@ -13256,9 +13667,9 @@ class ValidateCustomDomainOutput(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.custom_domain_validated = None - self.reason = None - self.message = None + self.custom_domain_validated: Optional[bool] = None + self.reason: Optional[str] = None + self.message: Optional[str] = None class ValidateProbeInput(_serialization.Model): @@ -13315,9 +13726,9 @@ class ValidateProbeOutput(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.is_valid = None - self.error_code = None - self.message = None + self.is_valid: Optional[bool] = None + self.error_code: Optional[str] = None + self.message: Optional[str] = None class ValidateSecretInput(_serialization.Model): @@ -13330,7 +13741,7 @@ class ValidateSecretInput(_serialization.Model): :vartype secret_type: str or ~azure.mgmt.cdn.models.SecretType :ivar secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. Required. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar secret_version: Secret version, if customer is using a specific version. @@ -13362,7 +13773,7 @@ def __init__( :paramtype secret_type: str or ~azure.mgmt.cdn.models.SecretType :keyword secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. Required. :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference :keyword secret_version: Secret version, if customer is using a specific version. @@ -13424,7 +13835,7 @@ class ValidationToken(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.token = None + self.token: Optional[str] = None class WafMetricsResponse(_serialization.Model): @@ -13630,7 +14041,7 @@ def __init__( :paramtype group_values: list[str] :keyword metrics: :paramtype metrics: - list[~azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems] # pylint: disable=line-too-long + list[~azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems] """ super().__init__(**kwargs) self.group_values = group_values diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/__init__.py index ebcf7eb37437..5e05549bd0b7 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/__init__.py @@ -5,32 +5,38 @@ # 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 -from ._cdn_management_client_operations import CdnManagementClientOperationsMixin -from ._afd_profiles_operations import AFDProfilesOperations -from ._afd_custom_domains_operations import AFDCustomDomainsOperations -from ._afd_endpoints_operations import AFDEndpointsOperations -from ._afd_origin_groups_operations import AFDOriginGroupsOperations -from ._afd_origins_operations import AFDOriginsOperations -from ._routes_operations import RoutesOperations -from ._rule_sets_operations import RuleSetsOperations -from ._rules_operations import RulesOperations -from ._security_policies_operations import SecurityPoliciesOperations -from ._secrets_operations import SecretsOperations -from ._log_analytics_operations import LogAnalyticsOperations -from ._profiles_operations import ProfilesOperations -from ._endpoints_operations import EndpointsOperations -from ._origins_operations import OriginsOperations -from ._origin_groups_operations import OriginGroupsOperations -from ._custom_domains_operations import CustomDomainsOperations -from ._resource_usage_operations import ResourceUsageOperations -from ._operations import Operations -from ._edge_nodes_operations import EdgeNodesOperations -from ._policies_operations import PoliciesOperations -from ._managed_rule_sets_operations import ManagedRuleSetsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._cdn_management_client_operations import CdnManagementClientOperationsMixin # type: ignore +from ._afd_profiles_operations import AFDProfilesOperations # type: ignore +from ._afd_custom_domains_operations import AFDCustomDomainsOperations # type: ignore +from ._afd_endpoints_operations import AFDEndpointsOperations # type: ignore +from ._afd_origin_groups_operations import AFDOriginGroupsOperations # type: ignore +from ._afd_origins_operations import AFDOriginsOperations # type: ignore +from ._routes_operations import RoutesOperations # type: ignore +from ._rule_sets_operations import RuleSetsOperations # type: ignore +from ._rules_operations import RulesOperations # type: ignore +from ._security_policies_operations import SecurityPoliciesOperations # type: ignore +from ._secrets_operations import SecretsOperations # type: ignore +from ._log_analytics_operations import LogAnalyticsOperations # type: ignore +from ._profiles_operations import ProfilesOperations # type: ignore +from ._endpoints_operations import EndpointsOperations # type: ignore +from ._origins_operations import OriginsOperations # type: ignore +from ._origin_groups_operations import OriginGroupsOperations # type: ignore +from ._custom_domains_operations import CustomDomainsOperations # type: ignore +from ._resource_usage_operations import ResourceUsageOperations # type: ignore +from ._operations import Operations # type: ignore +from ._edge_nodes_operations import EdgeNodesOperations # type: ignore +from ._policies_operations import PoliciesOperations # type: ignore +from ._managed_rule_sets_operations import ManagedRuleSetsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -57,5 +63,5 @@ "PoliciesOperations", "ManagedRuleSetsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py index 43dffe70d382..1a54935225d3 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_profile_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -83,19 +83,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -117,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -125,12 +127,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -154,7 +158,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -162,12 +166,14 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -191,19 +197,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -225,19 +233,21 @@ def build_refresh_validation_token_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}/refreshValidationToken", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -267,10 +277,10 @@ class AFDCustomDomainsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -280,8 +290,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either AFDDomain or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDDomain] @@ -293,7 +303,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDDomainListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -312,7 +322,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -328,7 +337,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -367,8 +375,8 @@ def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -377,7 +385,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.AFDDomain :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,7 +408,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -415,7 +422,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -429,8 +436,8 @@ def _create_initial( custom_domain_name: str, custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,7 +450,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -465,10 +472,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -476,21 +483,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 201: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -512,8 +517,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -543,8 +548,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -572,8 +577,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -607,10 +612,11 @@ def begin_create( 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("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -641,8 +647,8 @@ def _update_initial( custom_domain_name: str, custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -655,7 +661,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -677,10 +683,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -688,18 +694,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -721,8 +728,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -752,8 +759,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -781,8 +788,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -817,10 +824,11 @@ def begin_update( 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("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -844,10 +852,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -859,7 +867,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -870,10 +878,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -881,6 +889,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -889,8 +901,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -901,8 +917,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -920,7 +936,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -930,6 +946,7 @@ def begin_delete( 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 @@ -953,10 +970,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements + def _refresh_validation_token_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -968,7 +985,7 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_refresh_validation_token_request( resource_group_name=resource_group_name, @@ -979,10 +996,10 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -990,6 +1007,10 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -998,8 +1019,12 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_refresh_validation_token( @@ -1009,8 +1034,8 @@ def begin_refresh_validation_token( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. @@ -1028,7 +1053,7 @@ def begin_refresh_validation_token( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_validation_token_initial( # type: ignore + raw_result = self._refresh_validation_token_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -1038,6 +1063,7 @@ def begin_refresh_validation_token( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py index f4f0f3e5c5c8..7cad7b08189c 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_profile_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -83,19 +83,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -117,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -125,12 +127,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -154,7 +158,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -162,12 +166,14 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -191,19 +197,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -225,7 +233,7 @@ def build_purge_content_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -233,12 +241,14 @@ def build_purge_content_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/purge", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -262,19 +272,21 @@ def build_list_resource_usage_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/usages", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -296,7 +308,7 @@ def build_validate_custom_domain_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -304,12 +316,14 @@ def build_validate_custom_domain_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/validateCustomDomain", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -341,10 +355,10 @@ class AFDEndpointsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -354,8 +368,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDEndpoint] @@ -367,7 +381,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDEndpointListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,7 +400,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -402,7 +415,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -441,8 +453,8 @@ def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -451,7 +463,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.AFDEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,7 +486,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -489,7 +500,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -503,8 +514,8 @@ def _create_initial( endpoint_name: str, endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -517,7 +528,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -539,10 +550,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -550,21 +561,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -587,8 +596,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -620,8 +629,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -651,8 +660,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -687,10 +696,11 @@ def begin_create( 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("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -721,8 +731,8 @@ def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -735,7 +745,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -757,10 +767,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -768,18 +778,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -804,8 +815,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -839,8 +850,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -872,8 +883,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -909,10 +920,11 @@ def begin_update( 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("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -936,10 +948,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -951,7 +963,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -962,10 +974,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -973,6 +985,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -981,8 +997,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -993,8 +1013,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1012,7 +1032,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1022,6 +1042,7 @@ def begin_delete( 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 @@ -1045,15 +1066,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _purge_content_initial( # pylint: disable=inconsistent-return-statements + def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1066,7 +1087,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1088,10 +1109,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1099,6 +1120,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1107,8 +1132,12 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_purge_content( @@ -1125,8 +1154,8 @@ def begin_purge_content( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1159,8 +1188,8 @@ def begin_purge_content( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1191,8 +1220,8 @@ def begin_purge_content( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1216,7 +1245,7 @@ def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._purge_content_initial( # type: ignore + raw_result = self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1228,6 +1257,7 @@ def begin_purge_content( 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 @@ -1259,8 +1289,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1275,7 +1305,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1295,7 +1325,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1311,7 +1340,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1357,8 +1385,8 @@ def validate_custom_domain( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1389,8 +1417,8 @@ def validate_custom_domain( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1419,8 +1447,8 @@ def validate_custom_domain( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -1432,7 +1460,7 @@ def validate_custom_domain( :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1467,7 +1495,6 @@ def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1482,7 +1509,7 @@ def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py index 4280339143c6..5c4c1c15a3f4 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_profile_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -83,19 +83,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -117,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -125,12 +127,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -154,7 +158,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -162,12 +166,14 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -191,19 +197,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -225,19 +233,21 @@ def build_list_resource_usage_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/usages", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -267,10 +277,10 @@ class AFDOriginGroupsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -280,8 +290,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -293,7 +303,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOriginGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -312,7 +322,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -328,7 +337,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -366,8 +374,8 @@ def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -376,7 +384,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +407,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -414,7 +421,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -428,8 +435,8 @@ def _create_initial( origin_group_name: str, origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,7 +449,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -464,10 +471,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -475,21 +482,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -511,8 +516,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -543,8 +548,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -573,8 +578,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -609,10 +614,11 @@ def begin_create( 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("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -643,8 +649,8 @@ def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -657,7 +663,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -679,10 +685,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -690,18 +696,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -723,8 +730,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -755,8 +762,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -785,8 +792,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -822,10 +829,11 @@ def begin_update( 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("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -849,10 +857,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -864,7 +872,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -875,10 +883,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -886,6 +894,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -894,8 +906,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -905,8 +921,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -924,7 +940,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -934,6 +950,7 @@ def begin_delete( 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 @@ -965,8 +982,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. @@ -981,7 +998,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1001,7 +1018,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1017,7 +1033,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py index 72245c2a7c7f..1a9943bd73ec 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_origin_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -89,19 +89,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "originName": _SERIALIZER.url("origin_name", origin_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -129,7 +131,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,12 +139,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "originName": _SERIALIZER.url("origin_name", origin_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -172,7 +176,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -180,12 +184,14 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "originName": _SERIALIZER.url("origin_name", origin_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -215,19 +221,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), "originName": _SERIALIZER.url("origin_name", origin_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -258,10 +266,10 @@ class AFDOriginsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_origin_group( @@ -271,8 +279,8 @@ def list_by_origin_group( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -287,7 +295,7 @@ def list_by_origin_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOriginListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +315,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +330,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -361,8 +367,8 @@ def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -373,7 +379,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.AFDOrigin :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -397,7 +403,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -412,7 +417,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -427,8 +432,8 @@ def _create_initial( origin_name: str, origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,7 +446,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -464,10 +469,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -475,21 +480,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -512,8 +515,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -546,8 +549,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -578,8 +581,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -615,10 +618,11 @@ def begin_create( 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("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -650,8 +654,8 @@ def _update_initial( origin_name: str, origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -664,7 +668,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -687,10 +691,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -698,18 +702,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -732,8 +737,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -766,8 +771,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -798,8 +803,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -836,10 +841,11 @@ def begin_update( 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("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -863,10 +869,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -878,7 +884,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -890,10 +896,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -901,6 +907,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -909,8 +919,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -920,8 +934,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param origin_group_name: Name of the origin group which is unique within the profile. Required. @@ -941,7 +955,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -952,6 +966,7 @@ def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py index fee3bbbd97ad..cbba66f244b8 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +48,7 @@ def build_check_endpoint_name_availability_request( # pylint: disable=name-too- _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -58,7 +56,7 @@ def build_check_endpoint_name_availability_request( # pylint: disable=name-too- _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkEndpointNameAvailability", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -88,19 +86,21 @@ def build_list_resource_usage_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/usages", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -121,7 +121,7 @@ def build_check_host_name_availability_request( # 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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,12 +129,14 @@ def build_check_host_name_availability_request( # pylint: disable=name-too-long _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkHostNameAvailability", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -157,7 +159,7 @@ def build_validate_secret_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -165,7 +167,7 @@ def build_validate_secret_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/validateSecret", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -195,7 +197,7 @@ def build_upgrade_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +205,7 @@ def build_upgrade_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/upgrade", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -241,10 +243,10 @@ class AFDProfilesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def check_endpoint_name_availability( @@ -327,7 +329,7 @@ def check_endpoint_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -361,7 +363,6 @@ def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,7 +377,7 @@ def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -391,8 +392,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] @@ -404,7 +405,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,7 +424,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -439,7 +439,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -484,8 +483,8 @@ def check_host_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Required. :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput @@ -512,8 +511,8 @@ def check_host_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Required. :type check_host_name_availability_input: IO[bytes] @@ -538,8 +537,8 @@ def check_host_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Is either a CheckHostNameAvailabilityInput type or a IO[bytes] type. Required. @@ -549,7 +548,7 @@ def check_host_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,7 +582,6 @@ def check_host_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -598,7 +596,7 @@ def check_host_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -681,7 +679,7 @@ def validate_secret( :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +713,6 @@ def validate_secret( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -730,7 +727,7 @@ def validate_secret( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) + deserialized = self._deserialize("ValidateSecretOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -743,8 +740,8 @@ def _upgrade_initial( profile_name: str, profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -757,7 +754,7 @@ def _upgrade_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -778,10 +775,10 @@ def _upgrade_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -789,18 +786,19 @@ def _upgrade_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -904,10 +902,11 @@ def begin_upgrade( 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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py index 0040b37a9a66..0b5a5ffb9f9c 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,20 +20,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Serializer +from .._utils.utils import ClientMixinABC -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_check_endpoint_name_availability_request( # pylint: disable=name-too- _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -54,7 +51,7 @@ def build_check_endpoint_name_availability_request( # pylint: disable=name-too- _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/checkEndpointNameAvailability", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -79,7 +76,7 @@ def build_check_name_availability_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -103,7 +100,7 @@ def build_check_name_availability_with_subscription_request( # pylint: disable= _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -130,7 +127,7 @@ def build_validate_probe_request(subscription_id: str, **kwargs: Any) -> HttpReq _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,7 +150,7 @@ def build_validate_probe_request(subscription_id: str, **kwargs: Any) -> HttpReq return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class CdnManagementClientOperationsMixin(CdnManagementClientMixinABC): +class CdnManagementClientOperationsMixin(ClientMixinABC[PipelineClient, CdnManagementClientConfiguration]): @overload def check_endpoint_name_availability( @@ -224,7 +221,7 @@ def check_endpoint_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +254,6 @@ def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -272,7 +268,7 @@ def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -332,7 +328,7 @@ def check_name_availability( :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +359,6 @@ def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -378,7 +373,7 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -438,7 +433,7 @@ def check_name_availability_with_subscription( # pylint: disable=name-too-long :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,7 +465,6 @@ def check_name_availability_with_subscription( # pylint: disable=name-too-long headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -485,7 +479,7 @@ def check_name_availability_with_subscription( # pylint: disable=name-too-long error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -543,7 +537,7 @@ def validate_probe( :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,7 +569,6 @@ def validate_probe( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -590,7 +583,7 @@ def validate_probe( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) + deserialized = self._deserialize("ValidateProbeOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py index 54de16bb9e4c..9c1cd970be6e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,14 +48,14 @@ def build_list_by_endpoint_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -89,14 +87,14 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -129,7 +127,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,7 +135,7 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -172,14 +170,14 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -212,14 +210,14 @@ def build_disable_custom_https_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/disableCustomHttps", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -252,7 +250,7 @@ def build_enable_custom_https_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -260,7 +258,7 @@ def build_enable_custom_https_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/enableCustomHttps", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -298,10 +296,10 @@ class CustomDomainsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -327,7 +325,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomainListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,7 +345,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -363,7 +360,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -413,7 +409,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.CustomDomain :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -437,7 +433,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -452,7 +447,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -467,8 +462,8 @@ def _create_initial( custom_domain_name: str, custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -481,7 +476,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -504,10 +499,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -515,21 +510,19 @@ def _create_initial( 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 == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -659,10 +652,11 @@ def begin_create( 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("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -686,8 +680,8 @@ def get_long_running_output(pipeline_response): def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> Optional[_models.CustomDomain]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -699,7 +693,7 @@ def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.CustomDomain]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -711,10 +705,10 @@ def _delete_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -722,16 +716,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -779,6 +776,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -786,7 +784,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -810,8 +808,8 @@ def get_long_running_output(pipeline_response): def _disable_custom_https_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -823,7 +821,7 @@ def _disable_custom_https_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_disable_custom_https_request( resource_group_name=resource_group_name, @@ -835,10 +833,10 @@ def _disable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -846,18 +844,19 @@ def _disable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -905,10 +904,11 @@ def begin_disable_custom_https( 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("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -938,8 +938,8 @@ def _enable_custom_https_initial( custom_domain_name: str, custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -952,7 +952,7 @@ def _enable_custom_https_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -978,10 +978,10 @@ def _enable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -989,18 +989,19 @@ def _enable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1137,10 +1138,11 @@ def begin_enable_custom_https( 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("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py index ac995df5bfcd..4cb1e45d50e6 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,20 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,10 +69,10 @@ class EdgeNodesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> Iterable["_models.EdgeNode"]: @@ -94,7 +89,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.EdgeNode"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EdgenodeResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,7 +105,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -126,7 +120,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py index 28c4bba440d6..cc793d743564 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,14 +48,14 @@ def build_list_by_profile_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -83,14 +81,14 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -117,7 +115,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -125,7 +123,7 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -154,7 +152,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -162,7 +160,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -191,14 +189,14 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -225,14 +223,14 @@ def build_start_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -259,14 +257,14 @@ def build_stop_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -293,7 +291,7 @@ def build_purge_content_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -301,7 +299,7 @@ def build_purge_content_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -330,7 +328,7 @@ def build_load_content_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -338,7 +336,7 @@ def build_load_content_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -367,7 +365,7 @@ def build_validate_custom_domain_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -375,7 +373,7 @@ def build_validate_custom_domain_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/validateCustomDomain", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -404,14 +402,14 @@ def build_list_resource_usage_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/checkResourceUsage", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -446,10 +444,10 @@ class EndpointsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -472,7 +470,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +489,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -507,7 +504,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -554,7 +550,7 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * :rtype: ~azure.mgmt.cdn.models.Endpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,7 +573,6 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -592,7 +587,7 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -606,8 +601,8 @@ def _create_initial( endpoint_name: str, endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -620,7 +615,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -642,10 +637,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -653,21 +648,19 @@ def _create_initial( 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -786,10 +779,11 @@ def begin_create( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -818,8 +812,8 @@ def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -832,7 +826,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -854,10 +848,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -865,18 +859,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1002,10 +997,11 @@ def begin_update( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1027,10 +1023,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1042,7 +1038,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1053,10 +1049,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1064,6 +1060,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -1072,8 +1072,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1103,7 +1107,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1113,6 +1117,7 @@ def begin_delete( 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 @@ -1136,8 +1141,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- def _start_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1149,7 +1154,7 @@ def _start_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_start_request( resource_group_name=resource_group_name, @@ -1160,10 +1165,10 @@ def _start_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1171,18 +1176,19 @@ def _start_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1226,10 +1232,11 @@ def begin_start( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1253,8 +1260,8 @@ def get_long_running_output(pipeline_response): def _stop_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1266,7 +1273,7 @@ def _stop_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_stop_request( resource_group_name=resource_group_name, @@ -1277,10 +1284,10 @@ def _stop_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1288,18 +1295,19 @@ def _stop_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1343,10 +1351,11 @@ def begin_stop( 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("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1368,15 +1377,15 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _purge_content_initial( # pylint: disable=inconsistent-return-statements + def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1389,7 +1398,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1411,10 +1420,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1422,6 +1431,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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) @@ -1430,8 +1443,12 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_purge_content( @@ -1537,7 +1554,7 @@ def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._purge_content_initial( # type: ignore + raw_result = self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1549,6 +1566,7 @@ def begin_purge_content( 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 @@ -1570,15 +1588,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _load_content_initial( # pylint: disable=inconsistent-return-statements + def _load_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1591,7 +1609,7 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1613,10 +1631,10 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1624,6 +1642,10 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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) @@ -1632,8 +1654,12 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_load_content( @@ -1736,7 +1762,7 @@ def begin_load_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._load_content_initial( # type: ignore + raw_result = self._load_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1748,6 +1774,7 @@ def begin_load_content( 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 @@ -1857,7 +1884,7 @@ def validate_custom_domain( :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1892,7 +1919,6 @@ def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1907,7 +1933,7 @@ def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1938,7 +1964,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1958,7 +1984,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1974,7 +1999,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py index da8ececd9538..c0bbb25deb84 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by 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 -import sys -from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,20 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -59,14 +55,14 @@ def build_get_log_analytics_metrics_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsMetrics", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -118,14 +114,14 @@ def build_get_log_analytics_rankings_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsRankings", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -160,14 +156,14 @@ def build_get_log_analytics_locations_request( # 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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsLocations", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -193,14 +189,14 @@ def build_get_log_analytics_resources_request( # 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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsResources", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -237,14 +233,14 @@ def build_get_waf_log_analytics_metrics_request( # pylint: disable=name-too-lon _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsMetrics", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -291,14 +287,14 @@ def build_get_waf_log_analytics_rankings_request( # pylint: disable=name-too-lo _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsRankings", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -341,10 +337,10 @@ class LogAnalyticsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) 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_log_analytics_metrics( @@ -391,7 +387,7 @@ def get_log_analytics_metrics( :rtype: ~azure.mgmt.cdn.models.MetricsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +418,6 @@ def get_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -437,7 +432,7 @@ def get_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MetricsResponse", pipeline_response) + deserialized = self._deserialize("MetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -480,7 +475,7 @@ def get_log_analytics_rankings( :rtype: ~azure.mgmt.cdn.models.RankingsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,7 +503,6 @@ def get_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -523,7 +517,7 @@ def get_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RankingsResponse", pipeline_response) + deserialized = self._deserialize("RankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -545,7 +539,7 @@ def get_log_analytics_locations( :rtype: ~azure.mgmt.cdn.models.ContinentsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -567,7 +561,6 @@ def get_log_analytics_locations( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -582,7 +575,7 @@ def get_log_analytics_locations( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContinentsResponse", pipeline_response) + deserialized = self._deserialize("ContinentsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -604,7 +597,7 @@ def get_log_analytics_resources( :rtype: ~azure.mgmt.cdn.models.ResourcesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -626,7 +619,6 @@ def get_log_analytics_resources( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -641,7 +633,7 @@ def get_log_analytics_resources( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourcesResponse", pipeline_response) + deserialized = self._deserialize("ResourcesResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -687,7 +679,7 @@ def get_waf_log_analytics_metrics( :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -716,7 +708,6 @@ def get_waf_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -731,7 +722,7 @@ def get_waf_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafMetricsResponse", pipeline_response) + deserialized = self._deserialize("WafMetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -777,7 +768,7 @@ def get_waf_log_analytics_rankings( :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -806,7 +797,6 @@ def get_waf_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -821,7 +811,7 @@ def get_waf_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafRankingsResponse", pipeline_response) + deserialized = self._deserialize("WafRankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py index 4d8243ab3d6e..c8c3f880af9f 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,20 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,14 +40,14 @@ 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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/cdnWebApplicationFirewallManagedRuleSets", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -82,10 +77,10 @@ class ManagedRuleSetsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> Iterable["_models.ManagedRuleSetDefinition"]: @@ -102,7 +97,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedRuleSetDefinitionList] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,7 +114,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -135,7 +129,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py index 10d99a59fca4..f1dbab2ebb96 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,20 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,10 +69,10 @@ class Operations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> Iterable["_models.Operation"]: @@ -93,7 +88,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,7 +104,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +119,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py index aeca4d14e338..a968c8c72da2 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,14 +48,14 @@ def build_list_by_endpoint_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -89,14 +87,14 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -129,7 +127,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,7 +135,7 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -172,7 +170,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -180,7 +178,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -215,14 +213,14 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -258,10 +256,10 @@ class OriginGroupsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -287,7 +285,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OriginGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +305,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +320,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -374,7 +370,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.OriginGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,7 +394,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -413,7 +408,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -428,8 +423,8 @@ def _create_initial( origin_group_name: str, origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,7 +437,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -465,10 +460,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -476,21 +471,19 @@ def _create_initial( 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 == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -623,10 +616,11 @@ def begin_create( 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("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -656,8 +650,8 @@ def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -670,7 +664,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -693,10 +687,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -704,18 +698,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -849,10 +844,11 @@ def begin_update( 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("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -874,10 +870,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -889,7 +885,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -901,10 +897,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -912,6 +908,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -920,8 +920,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -953,7 +957,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -964,6 +968,7 @@ def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py index 3f181ef33b4b..389e38841934 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,14 +48,14 @@ def build_list_by_endpoint_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -89,14 +87,14 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -129,7 +127,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,7 +135,7 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -172,7 +170,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -180,7 +178,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -215,14 +213,14 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -258,10 +256,10 @@ class OriginsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -287,7 +285,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OriginListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +305,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +320,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -373,7 +369,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.Origin :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -397,7 +393,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -412,7 +407,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -427,8 +422,8 @@ def _create_initial( origin_name: str, origin: Union[_models.Origin, IO[bytes]], **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,7 +436,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -464,10 +459,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -475,21 +470,19 @@ def _create_initial( 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 == 200: - deserialized = self._deserialize("Origin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -615,10 +608,11 @@ def begin_create( 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("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -648,8 +642,8 @@ def _update_initial( origin_name: str, origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -662,7 +656,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -685,10 +679,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -696,18 +690,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -834,10 +829,11 @@ def begin_update( 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("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -859,10 +855,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -874,7 +870,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -886,10 +882,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -897,6 +893,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -905,8 +905,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -937,7 +941,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -948,6 +952,7 @@ def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py index a0594244f2de..fc727b35b8c3 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,14 +46,14 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -83,14 +81,14 @@ def build_get_request(resource_group_name: str, policy_name: str, subscription_i _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -121,7 +119,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +127,7 @@ def build_create_or_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -162,7 +160,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,7 +168,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -203,14 +201,14 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -249,10 +247,10 @@ class PoliciesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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, **kwargs: Any) -> Iterable["_models.CdnWebApplicationFirewallPolicy"]: @@ -271,7 +269,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cdn api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CdnWebApplicationFirewallPolicyList] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +287,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -305,7 +302,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -347,7 +343,7 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,7 +365,6 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -384,7 +379,7 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -397,8 +392,8 @@ def _create_or_update_initial( policy_name: str, cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -411,7 +406,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -432,10 +427,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -443,21 +438,19 @@ def _create_or_update_initial( 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 == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -563,10 +556,11 @@ def begin_create_or_update( 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("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -596,8 +590,8 @@ def _update_initial( _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -610,7 +604,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -633,10 +627,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -644,18 +638,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -769,10 +764,11 @@ def begin_update( 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("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -808,7 +804,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -830,7 +826,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py index 6a16d3bf4d1d..53fcce5e3b6f 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +46,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,14 +70,14 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -102,14 +100,14 @@ def build_get_request(resource_group_name: str, profile_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -135,7 +133,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -143,7 +141,7 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -171,7 +169,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -179,7 +177,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -207,14 +205,14 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -238,7 +236,7 @@ def build_can_migrate_request(resource_group_name: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -246,7 +244,7 @@ def build_can_migrate_request(resource_group_name: str, subscription_id: str, ** _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/canMigrate", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -271,7 +269,7 @@ def build_migrate_request(resource_group_name: str, subscription_id: str, **kwar _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -279,7 +277,7 @@ def build_migrate_request(resource_group_name: str, subscription_id: str, **kwar _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/migrate", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -306,14 +304,14 @@ def build_migration_commit_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationCommit", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -339,14 +337,14 @@ def build_generate_sso_uri_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/generateSsoUri", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -372,14 +370,14 @@ def build_list_supported_optimization_types_request( # pylint: disable=name-too _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getSupportedOptimizationTypes", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -405,14 +403,14 @@ def build_list_resource_usage_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkResourceUsage", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" @@ -432,7 +430,115 @@ def build_list_resource_usage_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ProfilesOperations: +def build_cdn_can_migrate_to_afd_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/cdnCanMigrateToAfd", + ) + 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 + ), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_cdn_migrate_to_afd_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) + content_type: 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.Cdn/profiles/{profileName}/cdnMigrateToAfd", + ) + 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 + ), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_migration_abort_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationAbort", + ) + 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 + ), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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 ProfilesOperations: # pylint: disable=too-many-public-methods """ .. warning:: **DO NOT** instantiate this class directly. @@ -446,10 +552,10 @@ class ProfilesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> Iterable["_models.Profile"]: @@ -466,7 +572,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProfileListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,7 +589,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -499,7 +604,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -546,7 +650,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProfileListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -564,7 +668,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -580,7 +683,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -624,7 +726,7 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo :rtype: ~azure.mgmt.cdn.models.Profile :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,7 +748,6 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -661,7 +762,7 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -670,8 +771,8 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo def _create_initial( self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -684,7 +785,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -705,10 +806,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -716,21 +817,19 @@ def _create_initial( 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 == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -833,10 +932,11 @@ def begin_create( 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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -864,8 +964,8 @@ def _update_initial( profile_name: str, profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -878,7 +978,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -899,10 +999,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -910,18 +1010,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1030,10 +1131,11 @@ def begin_update( 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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1055,10 +1157,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + def _delete_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1070,7 +1170,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1080,10 +1180,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1091,6 +1191,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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) @@ -1099,8 +1203,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1126,7 +1234,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -1135,6 +1243,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An 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 @@ -1161,8 +1270,8 @@ def _can_migrate_initial( resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CanMigrateResult]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1175,7 +1284,7 @@ def _can_migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CanMigrateResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1195,10 +1304,10 @@ def _can_migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1206,18 +1315,20 @@ def _can_migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CanMigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1312,10 +1423,11 @@ def begin_can_migrate( 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("CanMigrateResult", pipeline_response) + deserialized = self._deserialize("CanMigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1344,8 +1456,8 @@ def _migrate_initial( resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO[bytes]], **kwargs: Any - ) -> _models.MigrateResult: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1358,7 +1470,7 @@ def _migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MigrateResult] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1378,10 +1490,10 @@ def _migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1389,18 +1501,19 @@ def _migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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 == 200: - deserialized = self._deserialize("MigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("MigrateResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1497,10 +1610,11 @@ def begin_migrate( 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("MigrateResult", pipeline_response) + deserialized = self._deserialize("MigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1524,10 +1638,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migration_commit_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + def _migration_commit_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1539,7 +1651,7 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_migration_commit_request( resource_group_name=resource_group_name, @@ -1549,10 +1661,10 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1560,6 +1672,10 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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) @@ -1568,8 +1684,12 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_migration_commit(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1593,7 +1713,7 @@ def begin_migration_commit(self, resource_group_name: str, profile_name: str, ** lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._migration_commit_initial( # type: ignore + raw_result = self._migration_commit_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -1602,6 +1722,7 @@ def begin_migration_commit(self, resource_group_name: str, profile_name: str, ** 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 @@ -1642,7 +1763,7 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs :rtype: ~azure.mgmt.cdn.models.SsoUri :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1664,7 +1785,6 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1679,7 +1799,7 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SsoUri", pipeline_response) + deserialized = self._deserialize("SsoUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1702,7 +1822,7 @@ def list_supported_optimization_types( :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1724,7 +1844,6 @@ def list_supported_optimization_types( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1739,7 +1858,7 @@ def list_supported_optimization_types( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) + deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1768,7 +1887,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1787,7 +1906,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1803,7 +1921,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1832,3 +1949,434 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) + + def _cdn_can_migrate_to_afd_initial( + self, resource_group_name: str, profile_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_cdn_can_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_cdn_can_migrate_to_afd( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> LROPoller[_models.CanMigrateResult]: + """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :return: An instance of LROPoller that returns either CanMigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CanMigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cdn_can_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_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("CanMigrateResult", 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.CanMigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CanMigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _cdn_migrate_to_afd_initial( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, 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(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _json = self._serialize.body(migration_parameters, "CdnMigrationToAfdParameters") + + _request = build_cdn_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: _models.CdnMigrationToAfdParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters + :keyword content_type: Body Parameter 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 MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: IO[bytes] + :keyword content_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 MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Is either a + CdnMigrationToAfdParameters type or a IO[bytes] type. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters or IO[bytes] + :return: An instance of LROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_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.MigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cdn_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + migration_parameters=migration_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("MigrateResult", 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.MigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.MigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _migration_abort_initial(self, resource_group_name: str, profile_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_migration_abort_request( + resource_group_name=resource_group_name, + profile_name=profile_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]: + try: + response.read() # Load the body 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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_migration_abort(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: + """Abort the migration to Azure Frontdoor Premium/Standard. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_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._migration_abort_initial( + resource_group_name=resource_group_name, + profile_name=profile_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/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py index cadf0a85721a..cfe9a8194d24 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,20 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,10 +74,10 @@ class ResourceUsageOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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) -> Iterable["_models.ResourceUsage"]: @@ -98,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ResourceUsage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +110,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -131,7 +125,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py index 0b9de673cfe5..e51956a2209e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_endpoint_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -89,19 +89,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "routeName": _SERIALIZER.url("route_name", route_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -129,7 +131,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,12 +139,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "routeName": _SERIALIZER.url("route_name", route_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -172,7 +176,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -180,12 +184,14 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "routeName": _SERIALIZER.url("route_name", route_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -215,19 +221,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), "routeName": _SERIALIZER.url("route_name", route_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -258,10 +266,10 @@ class RoutesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_endpoint( @@ -271,8 +279,8 @@ def list_by_endpoint( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -287,7 +295,7 @@ def list_by_endpoint( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RouteListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +315,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +330,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -362,8 +368,8 @@ def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -374,7 +380,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.Route :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,7 +404,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -413,7 +418,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -428,8 +433,8 @@ def _create_initial( route_name: str, route: Union[_models.Route, IO[bytes]], **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,7 +447,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -465,10 +470,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -476,21 +481,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -514,8 +517,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -549,8 +552,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -582,8 +585,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -619,10 +622,11 @@ def begin_create( 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("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -654,8 +658,8 @@ def _update_initial( route_name: str, route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -668,7 +672,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -691,10 +695,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -702,18 +706,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -737,8 +742,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -772,8 +777,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -805,8 +810,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -843,10 +848,11 @@ def begin_update( 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("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -870,10 +876,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -885,7 +891,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -897,10 +903,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -908,6 +914,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -916,8 +926,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -928,8 +942,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. @@ -949,7 +963,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -960,6 +974,7 @@ def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py index 4f4fb842dd03..50ba46444baa 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,36 +6,34 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union, cast +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, TypeVar, Union, cast 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,19 +47,21 @@ def build_list_by_profile_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -82,19 +82,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -116,19 +118,21 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -150,19 +154,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -184,19 +190,21 @@ def build_list_resource_usage_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/usages", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -226,10 +234,10 @@ class RuleSetsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -239,8 +247,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either RuleSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.RuleSet] @@ -252,7 +260,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleSetListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,7 +279,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -287,7 +294,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -324,8 +330,8 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -334,7 +340,7 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +363,6 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -372,7 +377,7 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -385,8 +390,8 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -395,7 +400,7 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,7 +423,6 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,21 +437,17 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RuleSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -459,7 +459,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -470,10 +470,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -481,6 +481,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -489,8 +493,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -501,8 +509,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -520,7 +528,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -530,6 +538,7 @@ def begin_delete( 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 @@ -561,8 +570,8 @@ def list_resource_usage( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. @@ -577,7 +586,7 @@ def list_resource_usage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -597,7 +606,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -613,7 +621,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py index 02f15c6f1378..5e994afeed34 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_rule_set_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -84,19 +84,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -119,7 +121,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -127,12 +129,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -157,7 +161,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -165,12 +169,14 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -195,19 +201,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -238,10 +246,10 @@ class RulesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_rule_set( @@ -251,8 +259,8 @@ def list_by_rule_set( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -266,7 +274,7 @@ def list_by_rule_set( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,7 +294,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -302,7 +309,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -340,8 +346,8 @@ def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -351,7 +357,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.Rule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +381,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -390,7 +395,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -405,8 +410,8 @@ def _create_initial( rule_name: str, rule: Union[_models.Rule, IO[bytes]], **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,7 +424,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -442,10 +447,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -453,21 +458,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -490,8 +493,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -523,8 +526,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -554,8 +557,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -590,10 +593,11 @@ def begin_create( 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("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -625,8 +629,8 @@ def _update_initial( rule_name: str, rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,7 +643,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -662,10 +666,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -673,18 +677,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -707,8 +712,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -740,8 +745,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -771,8 +776,8 @@ def begin_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -808,10 +813,11 @@ def begin_update( 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("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -835,10 +841,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -850,7 +856,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -862,10 +868,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -873,6 +879,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -881,8 +891,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -892,8 +906,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str @@ -912,7 +926,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -923,6 +937,7 @@ def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py index 8f2d121d8a8b..680bdd73958d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_profile_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -83,19 +83,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -117,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -125,12 +127,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -154,19 +158,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -196,10 +202,10 @@ class SecretsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterable["_models.Secret"]: @@ -207,8 +213,8 @@ def list_by_profile(self, resource_group_name: str, profile_name: str, **kwargs: :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either Secret or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Secret] @@ -220,7 +226,7 @@ def list_by_profile(self, resource_group_name: str, profile_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecretListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,7 +245,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -255,7 +260,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -291,8 +295,8 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -300,7 +304,7 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k :rtype: ~azure.mgmt.cdn.models.Secret :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +327,6 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -338,7 +341,7 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -352,8 +355,8 @@ def _create_initial( secret_name: str, secret: Union[_models.Secret, IO[bytes]], **kwargs: Any - ) -> _models.Secret: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -366,7 +369,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -388,10 +391,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -399,21 +402,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -435,8 +436,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -465,8 +466,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -493,8 +494,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -526,10 +527,11 @@ def begin_create( 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("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -553,10 +555,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -568,7 +570,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -579,10 +581,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -590,6 +592,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -598,8 +604,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -609,8 +619,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str @@ -627,7 +637,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_name, @@ -637,6 +647,7 @@ def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py index 6d5a448a343f..5d7f568164ce 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,37 +6,35 @@ # Code generated by Microsoft (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 sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, 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.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +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 .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,19 +48,21 @@ def build_list_by_profile_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -83,19 +83,21 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -117,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -125,12 +127,14 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -154,7 +158,7 @@ def build_patch_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -162,12 +166,14 @@ def build_patch_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -191,19 +197,21 @@ def build_delete_request( _headers = case_insensitive_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-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -233,10 +241,10 @@ class SecurityPoliciesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CdnManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if 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_profile( @@ -246,8 +254,8 @@ def list_by_profile( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :return: An iterator like instance of either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.SecurityPolicy] @@ -259,7 +267,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecurityPolicyListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,7 +286,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -294,7 +301,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -332,8 +338,8 @@ def get( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -341,7 +347,7 @@ def get( :rtype: ~azure.mgmt.cdn.models.SecurityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +370,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -379,7 +384,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -393,8 +398,8 @@ def _create_initial( security_policy_name: str, security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +412,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -429,10 +434,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -440,21 +445,19 @@ def _create_initial( 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -476,8 +479,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -507,8 +510,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -536,8 +539,8 @@ def begin_create( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -571,10 +574,11 @@ def begin_create( 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("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -605,8 +609,8 @@ def _patch_initial( security_policy_name: str, security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,7 +623,7 @@ def _patch_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -641,10 +645,10 @@ def _patch_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -652,18 +656,19 @@ def _patch_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -685,8 +690,8 @@ def begin_patch( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -716,8 +721,8 @@ def begin_patch( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -745,8 +750,8 @@ def begin_patch( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -781,10 +786,11 @@ def begin_patch( 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("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -808,10 +814,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -823,7 +829,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = 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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -834,10 +840,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -845,6 +851,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -853,8 +863,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -864,8 +878,8 @@ def begin_delete( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile - which is unique within the resource group. Required. + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str @@ -882,7 +896,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -892,6 +906,7 @@ def begin_delete( 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 diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py index 232c2e014f9f..f2890ddf0cf9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,13 +39,21 @@ def main(): "properties": { "azureDnsZone": {"id": ""}, "hostName": "www.someDomain.net", - "tlsSettings": {"certificateType": "ManagedCertificate", "minimumTlsVersion": "TLS12"}, + "tlsSettings": { + "certificateType": "ManagedCertificate", + "cipherSuiteSetType": "Customized", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["ECDHE_RSA_AES128_GCM_SHA256"], + "cipherSuiteSetForTls13": ["TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384"], + }, + "minimumTlsVersion": "TLS12", + }, } }, ).result() print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDCustomDomains_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py index cdde1ccd7199..5a5cc7ebad18 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDCustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py index c529ac66adb1..b998594672a0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDCustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py index 9838f20f9aa9..584f1f259ed5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDCustomDomains_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py index 14687b97d07d..b65ec33948c2 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_RefreshValidationToken.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDCustomDomains_RefreshValidationToken.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py index 383d3fee790e..fdb83701fa37 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -39,13 +38,21 @@ def main(): custom_domain_update_properties={ "properties": { "azureDnsZone": {"id": ""}, - "tlsSettings": {"certificateType": "CustomerCertificate", "minimumTlsVersion": "TLS12"}, + "tlsSettings": { + "certificateType": "ManagedCertificate", + "cipherSuiteSetType": "Customized", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["ECDHE_RSA_AES128_GCM_SHA256"], + "cipherSuiteSetForTls13": ["TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384"], + }, + "minimumTlsVersion": "TLS12", + }, } }, ).result() print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDCustomDomains_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py index 6c47e4ba6e73..2dafd43cbc35 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py index 2d4f28011117..4fc86ba9e780 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py index eca25cfe859c..de075f2ae6ba 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py index b678db5bb2db..4b1981282078 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py index 656ee738021c..28f867b02ab8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py index aebb6dbb77e8..1353f8289ae5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_PurgeContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_PurgeContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py index f84366b6e02e..106b7a54b53f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py index 37fd7a89af3f..9e9953a898fb 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ValidateCustomDomain.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDEndpoints_ValidateCustomDomain.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py index 5f1a41348821..a488e99f2081 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -56,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOriginGroups_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py index 79952a91120c..a8cc84634a8c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOriginGroups_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py index 606b8be50db8..8283c2751535 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOriginGroups_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py index de8a9f7f5725..79a5012b7ca3 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOriginGroups_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py index 0297a249bcdb..99d9e5040c15 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOriginGroups_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py index 0a17f8587bb0..210e63945f5d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -56,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOriginGroups_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py index c42baa3cadc9..4e6c04dc7081 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -50,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOrigins_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py index d8e79eddaa4a..e964c8f4c1a7 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOrigins_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py index 4216fff73b9d..9024a3304f5c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOrigins_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py index 8aca66fa1ea7..1c911812043f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_ListByOriginGroup.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOrigins_ListByOriginGroup.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py index ffdd1c9eb0c4..beb8f812a624 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDOrigins_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py index 3cd89e63f42a..f59fc050e3df 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -44,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckEndpointNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDProfiles_CheckEndpointNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py index 0c58ab223c3d..56eb1bac627c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckHostNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDProfiles_CheckHostNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py index 7d952f353b0f..d48644232a11 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDProfiles_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py index 183a03ed50d9..2d5cd4f45f4d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_Upgrade.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDProfiles_Upgrade.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py index 66b34e4ba7d8..2da4b7df41c8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ValidateSecret.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/AFDProfiles_ValidateSecret.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_can_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_can_migrate.py new file mode 100644 index 000000000000..582a9b2a2804 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_can_migrate.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.cdn import CdnManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cdn +# USAGE + python cdn_profiles_can_migrate.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 = CdnManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.profiles.begin_cdn_can_migrate_to_afd( + resource_group_name="RG", + profile_name="profile1", + ).result() + print(response) + + +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CdnProfiles_CanMigrate.json +if __name__ == "__main__": + main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_migrate.py new file mode 100644 index 000000000000..3a69301ffeb0 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_migrate.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.cdn import CdnManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cdn +# USAGE + python cdn_profiles_migrate.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 = CdnManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.profiles.begin_cdn_migrate_to_afd( + resource_group_name="RG", + profile_name="profile1", + migration_parameters={"sku": {"name": "Standard_AzureFrontDoor"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CdnProfiles_Migrate.json +if __name__ == "__main__": + main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py index e674cea2011f..579ac88d449c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckEndpointNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CheckEndpointNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py index ef2972396a83..af2dd1f939c8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py index dafc98d6dee6..adb28d112908 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckNameAvailabilityWithSubscription.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CheckNameAvailabilityWithSubscription.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py index 7f0e634b4aa4..013d34b3c9ea 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CustomDomains_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py index 7861318578bd..96869d1fa54d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py index f9194bef7069..6d368e943433 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_DisableCustomHttps.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CustomDomains_DisableCustomHttps.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py index 4f88e220d426..5afd3bc5975b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_EnableCustomHttpsUsingBYOC.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CustomDomains_EnableCustomHttpsUsingBYOC.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py index c62b5e115f17..9a83c8738fe1 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_EnableCustomHttpsUsingCDNManagedCertificate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CustomDomains_EnableCustomHttpsUsingCDNManagedCertificate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py index 09b7e305b0e2..2e9decf561be 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py index 13a26666662b..441348202dd3 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/CustomDomains_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py index c7e2062ae372..f3899f22db97 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/EdgeNodes_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/EdgeNodes_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py index 9168c89ae5a4..c5af00326853 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -156,6 +155,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py index 39a54278d76d..d707b632ea08 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py index 301f9f733c6a..7590e79143ad 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py index f5461c728bc4..78ca458b767d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py index 405675b567fe..50cd6406aea4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py index 1cf246f15099..806a45c6b429 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_LoadContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_LoadContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py index 57adb262b0fa..8df620161544 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_PurgeContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_PurgeContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py index 87f3f2134ca8..66c3e6d1a706 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Start.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_Start.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py index d8ec097a2211..1ef47506e635 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Stop.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_Stop.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py index 828459ba88ef..9b8d3a4b5779 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py index af88a31d15c6..87b0224d1f29 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ValidateCustomDomain.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Endpoints_ValidateCustomDomain.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py index 3a8bd6124731..b995e25043d9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsLocations.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/LogAnalytics_GetLogAnalyticsLocations.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py index 99792edff08a..3e3687b7c08b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -50,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsMetrics.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/LogAnalytics_GetLogAnalyticsMetrics.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py index 1b476cdd4515..5eb5c73ef587 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -49,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsRankings.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/LogAnalytics_GetLogAnalyticsRankings.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py index ba65e42c3cef..b9de35a03c4a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsResources.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/LogAnalytics_GetLogAnalyticsResources.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py index bd7f9b3079db..8c11956f82c0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -48,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetWafLogAnalyticsMetrics.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/LogAnalytics_GetWafLogAnalyticsMetrics.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py index d6c05717d1e6..836d8d42bbaf 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -49,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetWafLogAnalyticsRankings.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/LogAnalytics_GetWafLogAnalyticsRankings.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py index 60380404b906..aafaf61b39c6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Operations_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py index 8fc8ae01c77a..fc71d362ca94 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -60,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/OriginGroups_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py index 16263ab85319..fb94649d6507 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/OriginGroups_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py index e0e64c28f83d..d78d4a639a13 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/OriginGroups_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py index 59a0711ca5a5..3d3a842205c6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/OriginGroups_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py index 9ca87890ab2c..37733bfa0ec0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -56,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/OriginGroups_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py index df360fce2549..3c291701cafd 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -55,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Origins_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py index 2e0262ae7112..0f3cab1b76d6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Origins_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py index babb5673bbf7..858112eaa078 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Origins_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py index 9841934192fd..3fb43e7f2930 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Origins_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py index 048a05562201..7139ab6cb2e3 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -52,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Origins_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py index 61208bef63d0..02811b4b8bb3 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_CanMigrate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_CanMigrate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py index 139587290691..da5d96e5071d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py index e15c08f6a878..bb9937a0125d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py index ccbc01208071..dba79b730c5d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_GenerateSsoUri.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_GenerateSsoUri.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py index 172c69425889..9de2c5f48fc5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py index d14470182ced..9ce84b2569bc 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py index b97c6fa4f15c..505a70b065d4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListByResourceGroup.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py index b4d07330bcbe..c9a92c6ac0d4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py index 2f16d6104d98..e0c855089513 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListSupportedOptimizationTypes.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_ListSupportedOptimizationTypes.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py index ff448f96f765..5cb0b16c5df9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Migrate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_Migrate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_abort.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_abort.py new file mode 100644 index 000000000000..22e36f2fe172 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_abort.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.cdn import CdnManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cdn +# USAGE + python profiles_migration_abort.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 = CdnManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.profiles.begin_migration_abort( + resource_group_name="RG", + profile_name="profile1", + ).result() + + +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_MigrationAbort.json +if __name__ == "__main__": + main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py index 39880c2a7040..5054cef7ec66 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_MigrationCommit.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_MigrationCommit.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py index 7a77aa5cf83a..6023f4d6963b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Profiles_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py index f13ebbc36df5..ef328da31345 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/ResourceUsage_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/ResourceUsage_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py index ac4b9aac1942..0949b02ec4ba 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -73,6 +72,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Routes_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py index 005a5640be13..a9c4442a0ed9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Routes_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py index 97d3bbb4ffed..c4e720705b47 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Routes_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py index 975bbf16c82e..52f4bbe7c895 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Routes_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py index 2e1431b0c52d..e195a77f60c8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -72,6 +71,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Routes_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py index e3c4d5ab619a..93eedb4b947a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/RuleSets_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py index 129ba69060cb..4e200ac77812 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/RuleSets_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py index 4108b7daa08e..a8468463d44e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/RuleSets_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py index 30b1fd7b2c27..0828cc8df0eb 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/RuleSets_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py index 310c77ba4f71..d01f351881a1 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/RuleSets_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py index 07e893135dd6..361323914891 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -68,6 +66,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Rules_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py index bae4e0fabfe8..89ec1a3fe042 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Rules_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py index 2e2505d9f09f..a5cd48ee6140 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Rules_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py index f096b56e948a..603608345573 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_ListByRuleSet.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Rules_ListByRuleSet.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py index ab1eb23507e3..4f6bf154a93d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -57,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Rules_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py index ce98279c2883..45b9e62b02d7 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -52,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Secrets_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py index 247d04c46c71..482f93f233c0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Secrets_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py index 18e6df120ff9..4b0fe4c8bb79 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Secrets_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py index a23988e572f4..908c1a3b4d2a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/Secrets_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py index 007ffa21a147..0b3cd55b20ea 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -63,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/SecurityPolicies_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py index 53a393cf71b8..89ee47b01a70 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/SecurityPolicies_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py index 9ffd420f9622..a10051445d3a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/SecurityPolicies_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py index a73aab33dff3..695f530cf775 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/SecurityPolicies_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py index 9bc7789afd81..3838ccb5cd32 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -63,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Patch.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/SecurityPolicies_Patch.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py index eb0e8b8c8ad5..910b4dbbcebf 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -38,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/ValidateProbe.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/ValidateProbe.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py index 8d0ee8e8fcb0..f164d00af063 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafListManagedRuleSets.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/WafListManagedRuleSets.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py index 94470f323fe4..50e8bff7cbfd 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafListPolicies.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/WafListPolicies.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py index 0478923b8574..cdb7bd3617be 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPatchPolicy.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/WafPatchPolicy.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py index 63b8ee7c267d..1370da83cc61 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -125,6 +124,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/WafPolicyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py index c0b10e7d8496..678a4302c4cc 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyDelete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/WafPolicyDelete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py index eecc00b102f2..8a386ec5a7a8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyGet.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2025-04-15/examples/WafPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/conftest.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/conftest.py new file mode 100644 index 000000000000..02cbe090acc4 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + cdnmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + cdnmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + cdnmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + cdnmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=cdnmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=cdnmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=cdnmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=cdnmanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management.py new file mode 100644 index 000000000000..d45076e8b80a --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagement(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_endpoint_name_availability(self, resource_group): + response = self.client.check_endpoint_name_availability( + resource_group_name=resource_group.name, + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.check_name_availability( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability_with_subscription(self, resource_group): + response = self.client.check_name_availability_with_subscription( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_validate_probe(self, resource_group): + response = self.client.validate_probe( + validate_probe_input={"probeURL": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations.py new file mode 100644 index 000000000000..ad5ea6c02fbb --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDCustomDomainsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_custom_domains_list_by_profile(self, resource_group): + response = self.client.afd_custom_domains.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_custom_domains_get(self, resource_group): + response = self.client.afd_custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_custom_domains_begin_create(self, resource_group): + response = self.client.afd_custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain={ + "azureDnsZone": {"id": "str"}, + "deploymentStatus": "str", + "domainValidationState": "str", + "extendedProperties": {"str": "str"}, + "hostName": "str", + "id": "str", + "name": "str", + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "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", + }, + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": {"cipherSuiteSetForTls12": ["str"], "cipherSuiteSetForTls13": ["str"]}, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + "type": "str", + "validationProperties": {"expirationDate": "str", "validationToken": "str"}, + }, + api_version="2025-04-15", + ).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_afd_custom_domains_begin_update(self, resource_group): + response = self.client.afd_custom_domains.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain_update_properties={ + "azureDnsZone": {"id": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": {"cipherSuiteSetForTls12": ["str"], "cipherSuiteSetForTls13": ["str"]}, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + }, + api_version="2025-04-15", + ).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_afd_custom_domains_begin_delete(self, resource_group): + response = self.client.afd_custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ).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_afd_custom_domains_begin_refresh_validation_token(self, resource_group): + response = self.client.afd_custom_domains.begin_refresh_validation_token( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations_async.py new file mode 100644 index 000000000000..b1c8f13bf14a --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations_async.py @@ -0,0 +1,152 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDCustomDomainsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_custom_domains_list_by_profile(self, resource_group): + response = self.client.afd_custom_domains.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_afd_custom_domains_get(self, resource_group): + response = await self.client.afd_custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_custom_domains_begin_create(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain={ + "azureDnsZone": {"id": "str"}, + "deploymentStatus": "str", + "domainValidationState": "str", + "extendedProperties": {"str": "str"}, + "hostName": "str", + "id": "str", + "name": "str", + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "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", + }, + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["str"], + "cipherSuiteSetForTls13": ["str"], + }, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + "type": "str", + "validationProperties": {"expirationDate": "str", "validationToken": "str"}, + }, + api_version="2025-04-15", + ) + ).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_afd_custom_domains_begin_update(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain_update_properties={ + "azureDnsZone": {"id": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["str"], + "cipherSuiteSetForTls13": ["str"], + }, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + }, + api_version="2025-04-15", + ) + ).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_afd_custom_domains_begin_delete(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + ).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_afd_custom_domains_begin_refresh_validation_token(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_refresh_validation_token( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations.py new file mode 100644 index 000000000000..c249e2d6533f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_endpoints_list_by_profile(self, resource_group): + response = self.client.afd_endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_endpoints_get(self, resource_group): + response = self.client.afd_endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_endpoints_begin_create(self, resource_group): + response = self.client.afd_endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "autoGeneratedDomainNameLabelScope": "str", + "deploymentStatus": "str", + "enabledState": "str", + "hostName": "str", + "id": "str", + "name": "str", + "profileName": "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", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-04-15", + ).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_afd_endpoints_begin_update(self, resource_group): + response = self.client.afd_endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={"enabledState": "str", "profileName": "str", "tags": {"str": "str"}}, + api_version="2025-04-15", + ).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_afd_endpoints_begin_delete(self, resource_group): + response = self.client.afd_endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ).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_afd_endpoints_begin_purge_content(self, resource_group): + response = self.client.afd_endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + contents={"contentPaths": ["str"], "domains": ["str"]}, + api_version="2025-04-15", + ).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_afd_endpoints_list_resource_usage(self, resource_group): + response = self.client.afd_endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_endpoints_validate_custom_domain(self, resource_group): + response = self.client.afd_endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations_async.py new file mode 100644 index 000000000000..07a113490320 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations_async.py @@ -0,0 +1,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_endpoints_list_by_profile(self, resource_group): + response = self.client.afd_endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_afd_endpoints_get(self, resource_group): + response = await self.client.afd_endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_endpoints_begin_create(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "autoGeneratedDomainNameLabelScope": "str", + "deploymentStatus": "str", + "enabledState": "str", + "hostName": "str", + "id": "str", + "name": "str", + "profileName": "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", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_afd_endpoints_begin_update(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={"enabledState": "str", "profileName": "str", "tags": {"str": "str"}}, + api_version="2025-04-15", + ) + ).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_afd_endpoints_begin_delete(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + ).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_afd_endpoints_begin_purge_content(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + contents={"contentPaths": ["str"], "domains": ["str"]}, + api_version="2025-04-15", + ) + ).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_afd_endpoints_list_resource_usage(self, resource_group): + response = self.client.afd_endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + 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_afd_endpoints_validate_custom_domain(self, resource_group): + response = await self.client.afd_endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations.py new file mode 100644 index 000000000000..e4afb957f682 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_origin_groups_list_by_profile(self, resource_group): + response = self.client.afd_origin_groups.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_origin_groups_get(self, resource_group): + response = self.client.afd_origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_origin_groups_begin_create(self, resource_group): + response = self.client.afd_origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group={ + "deploymentStatus": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "name": "str", + "profileName": "str", + "provisioningState": "str", + "sessionAffinityState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2025-04-15", + ).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_afd_origin_groups_begin_update(self, resource_group): + response = self.client.afd_origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2025-04-15", + ).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_afd_origin_groups_begin_delete(self, resource_group): + response = self.client.afd_origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ).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_afd_origin_groups_list_resource_usage(self, resource_group): + response = self.client.afd_origin_groups.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations_async.py new file mode 100644 index 000000000000..be0b9b1e218f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations_async.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_origin_groups_list_by_profile(self, resource_group): + response = self.client.afd_origin_groups.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_afd_origin_groups_get(self, resource_group): + response = await self.client.afd_origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_origin_groups_begin_create(self, resource_group): + response = await ( + await self.client.afd_origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group={ + "deploymentStatus": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "name": "str", + "profileName": "str", + "provisioningState": "str", + "sessionAffinityState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_afd_origin_groups_begin_update(self, resource_group): + response = await ( + await self.client.afd_origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2025-04-15", + ) + ).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_afd_origin_groups_begin_delete(self, resource_group): + response = await ( + await self.client.afd_origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + ).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_afd_origin_groups_list_resource_usage(self, resource_group): + response = self.client.afd_origin_groups.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations.py new file mode 100644 index 000000000000..c8476b615b9c --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations.py @@ -0,0 +1,139 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_origins_list_by_origin_group(self, resource_group): + response = self.client.afd_origins.list_by_origin_group( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_origins_get(self, resource_group): + response = self.client.afd_origins.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_origins_begin_create(self, resource_group): + response = self.client.afd_origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin={ + "azureOrigin": {"id": "str"}, + "deploymentStatus": "str", + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "id": "str", + "name": "str", + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "provisioningState": "str", + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "weight": 0, + }, + api_version="2025-04-15", + ).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_afd_origins_begin_update(self, resource_group): + response = self.client.afd_origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin_update_properties={ + "azureOrigin": {"id": "str"}, + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + }, + api_version="2025-04-15", + ).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_afd_origins_begin_delete(self, resource_group): + response = self.client.afd_origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py new file mode 100644 index 000000000000..6ac5b777d0f9 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_origins_list_by_origin_group(self, resource_group): + response = self.client.afd_origins.list_by_origin_group( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + 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_afd_origins_get(self, resource_group): + response = await self.client.afd_origins.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_origins_begin_create(self, resource_group): + response = await ( + await self.client.afd_origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin={ + "azureOrigin": {"id": "str"}, + "deploymentStatus": "str", + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "id": "str", + "name": "str", + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "provisioningState": "str", + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "weight": 0, + }, + api_version="2025-04-15", + ) + ).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_afd_origins_begin_update(self, resource_group): + response = await ( + await self.client.afd_origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin_update_properties={ + "azureOrigin": {"id": "str"}, + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + }, + api_version="2025-04-15", + ) + ).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_afd_origins_begin_delete(self, resource_group): + response = await ( + await self.client.afd_origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py new file mode 100644 index 000000000000..e2e47ba8a605 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_profiles_check_endpoint_name_availability(self, resource_group): + response = self.client.afd_profiles.check_endpoint_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_profiles_list_resource_usage(self, resource_group): + response = self.client.afd_profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_profiles_check_host_name_availability(self, resource_group): + response = self.client.afd_profiles.check_host_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_host_name_availability_input={"hostName": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_profiles_validate_secret(self, resource_group): + response = self.client.afd_profiles.validate_secret( + resource_group_name=resource_group.name, + profile_name="str", + validate_secret_input={"secretSource": {"id": "str"}, "secretType": "str", "secretVersion": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_afd_profiles_begin_upgrade(self, resource_group): + response = self.client.afd_profiles.begin_upgrade( + resource_group_name=resource_group.name, + profile_name="str", + profile_upgrade_parameters={ + "wafMappingList": [{"changeToWafPolicy": {"id": "str"}, "securityPolicyName": "str"}] + }, + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations_async.py new file mode 100644 index 000000000000..2893f53cd595 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations_async.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_profiles_check_endpoint_name_availability(self, resource_group): + response = await self.client.afd_profiles.check_endpoint_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_profiles_list_resource_usage(self, resource_group): + response = self.client.afd_profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_afd_profiles_check_host_name_availability(self, resource_group): + response = await self.client.afd_profiles.check_host_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_host_name_availability_input={"hostName": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_profiles_validate_secret(self, resource_group): + response = await self.client.afd_profiles.validate_secret( + resource_group_name=resource_group.name, + profile_name="str", + validate_secret_input={"secretSource": {"id": "str"}, "secretType": "str", "secretVersion": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_afd_profiles_begin_upgrade(self, resource_group): + response = await ( + await self.client.afd_profiles.begin_upgrade( + resource_group_name=resource_group.name, + profile_name="str", + profile_upgrade_parameters={ + "wafMappingList": [{"changeToWafPolicy": {"id": "str"}, "securityPolicyName": "str"}] + }, + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_async.py new file mode 100644 index 000000000000..cff665a776a4 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_endpoint_name_availability(self, resource_group): + response = await self.client.check_endpoint_name_availability( + resource_group_name=resource_group.name, + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.check_name_availability( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability_with_subscription(self, resource_group): + response = await self.client.check_name_availability_with_subscription( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_validate_probe(self, resource_group): + response = await self.client.validate_probe( + validate_probe_input={"probeURL": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py new file mode 100644 index 000000000000..e8ff14460fc2 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementCustomDomainsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_domains_list_by_endpoint(self, resource_group): + response = self.client.custom_domains.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_domains_get(self, resource_group): + response = self.client.custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_custom_domains_begin_create(self, resource_group): + response = self.client.custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2025-04-15", + ).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_custom_domains_begin_delete(self, resource_group): + response = self.client.custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ).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_custom_domains_begin_disable_custom_https(self, resource_group): + response = self.client.custom_domains.begin_disable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ).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_custom_domains_begin_enable_custom_https(self, resource_group): + response = self.client.custom_domains.begin_enable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations_async.py new file mode 100644 index 000000000000..e996e6bc9113 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementCustomDomainsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_domains_list_by_endpoint(self, resource_group): + response = self.client.custom_domains.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + 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_custom_domains_get(self, resource_group): + response = await self.client.custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_custom_domains_begin_create(self, resource_group): + response = await ( + await self.client.custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2025-04-15", + ) + ).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_custom_domains_begin_delete(self, resource_group): + response = await ( + await self.client.custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + ).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_custom_domains_begin_disable_custom_https(self, resource_group): + response = await ( + await self.client.custom_domains.begin_disable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + ).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_custom_domains_begin_enable_custom_https(self, resource_group): + response = await ( + await self.client.custom_domains.begin_enable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations.py new file mode 100644 index 000000000000..f426065b04b0 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEdgeNodesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_edge_nodes_list(self, resource_group): + response = self.client.edge_nodes.list( + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations_async.py new file mode 100644 index 000000000000..d51eaa233070 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEdgeNodesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_edge_nodes_list(self, resource_group): + response = self.client.edge_nodes.list( + api_version="2025-04-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations.py new file mode 100644 index 000000000000..f0f89848eaf0 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations.py @@ -0,0 +1,293 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_list_by_profile(self, resource_group): + response = self.client.endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_get(self, resource_group): + response = self.client.endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_begin_create(self, resource_group): + response = self.client.endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "contentTypesToCompress": ["str"], + "customDomains": [{"name": "str", "hostName": "str", "validationData": "str"}], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "hostName": "str", + "id": "str", + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "name": "str", + "optimizationType": "str", + "originGroups": [ + { + "name": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + } + ], + "originHostHeader": "str", + "originPath": "str", + "origins": [ + { + "name": "str", + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + ], + "probePath": "str", + "provisioningState": "str", + "queryStringCachingBehavior": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2025-04-15", + ).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_endpoints_begin_update(self, resource_group): + response = self.client.endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={ + "contentTypesToCompress": ["str"], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "optimizationType": "str", + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "queryStringCachingBehavior": "str", + "tags": {"str": "str"}, + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2025-04-15", + ).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_endpoints_begin_delete(self, resource_group): + response = self.client.endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ).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_endpoints_begin_start(self, resource_group): + response = self.client.endpoints.begin_start( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ).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_endpoints_begin_stop(self, resource_group): + response = self.client.endpoints.begin_stop( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ).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_endpoints_begin_purge_content(self, resource_group): + response = self.client.endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2025-04-15", + ).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_endpoints_begin_load_content(self, resource_group): + response = self.client.endpoints.begin_load_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2025-04-15", + ).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_endpoints_validate_custom_domain(self, resource_group): + response = self.client.endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_list_resource_usage(self, resource_group): + response = self.client.endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations_async.py new file mode 100644 index 000000000000..1a247881a06e --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations_async.py @@ -0,0 +1,308 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_endpoints_list_by_profile(self, resource_group): + response = self.client.endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_endpoints_get(self, resource_group): + response = await self.client.endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_endpoints_begin_create(self, resource_group): + response = await ( + await self.client.endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "contentTypesToCompress": ["str"], + "customDomains": [{"name": "str", "hostName": "str", "validationData": "str"}], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "hostName": "str", + "id": "str", + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "name": "str", + "optimizationType": "str", + "originGroups": [ + { + "name": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + } + ], + "originHostHeader": "str", + "originPath": "str", + "origins": [ + { + "name": "str", + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + ], + "probePath": "str", + "provisioningState": "str", + "queryStringCachingBehavior": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2025-04-15", + ) + ).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_endpoints_begin_update(self, resource_group): + response = await ( + await self.client.endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={ + "contentTypesToCompress": ["str"], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "optimizationType": "str", + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "queryStringCachingBehavior": "str", + "tags": {"str": "str"}, + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2025-04-15", + ) + ).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_endpoints_begin_delete(self, resource_group): + response = await ( + await self.client.endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + ).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_endpoints_begin_start(self, resource_group): + response = await ( + await self.client.endpoints.begin_start( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + ).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_endpoints_begin_stop(self, resource_group): + response = await ( + await self.client.endpoints.begin_stop( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + ).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_endpoints_begin_purge_content(self, resource_group): + response = await ( + await self.client.endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2025-04-15", + ) + ).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_endpoints_begin_load_content(self, resource_group): + response = await ( + await self.client.endpoints.begin_load_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2025-04-15", + ) + ).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_endpoints_validate_custom_domain(self, resource_group): + response = await self.client.endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_endpoints_list_resource_usage(self, resource_group): + response = self.client.endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations.py new file mode 100644 index 000000000000..a657050b1f68 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementLogAnalyticsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_analytics_get_log_analytics_metrics(self, resource_group): + response = self.client.log_analytics.get_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + custom_domains=["str"], + protocols=["str"], + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_analytics_get_log_analytics_rankings(self, resource_group): + response = self.client.log_analytics.get_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + rankings=["str"], + metrics=["str"], + max_ranking=0, + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_analytics_get_log_analytics_locations(self, resource_group): + response = self.client.log_analytics.get_log_analytics_locations( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_analytics_get_log_analytics_resources(self, resource_group): + response = self.client.log_analytics.get_log_analytics_resources( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_analytics_get_waf_log_analytics_metrics(self, resource_group): + response = self.client.log_analytics.get_waf_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_analytics_get_waf_log_analytics_rankings(self, resource_group): + response = self.client.log_analytics.get_waf_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + max_ranking=0, + rankings=["str"], + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations_async.py new file mode 100644 index 000000000000..fb13ba437dee --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementLogAnalyticsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_analytics_get_log_analytics_metrics(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + custom_domains=["str"], + protocols=["str"], + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_analytics_get_log_analytics_rankings(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + rankings=["str"], + metrics=["str"], + max_ranking=0, + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_analytics_get_log_analytics_locations(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_locations( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_analytics_get_log_analytics_resources(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_resources( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_analytics_get_waf_log_analytics_metrics(self, resource_group): + response = await self.client.log_analytics.get_waf_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_analytics_get_waf_log_analytics_rankings(self, resource_group): + response = await self.client.log_analytics.get_waf_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + max_ranking=0, + rankings=["str"], + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations.py new file mode 100644 index 000000000000..e8130204a81c --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementManagedRuleSetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_rule_sets_list(self, resource_group): + response = self.client.managed_rule_sets.list( + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations_async.py new file mode 100644 index 000000000000..68420d25ce4d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementManagedRuleSetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_rule_sets_list(self, resource_group): + response = self.client.managed_rule_sets.list( + api_version="2025-04-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations.py new file mode 100644 index 000000000000..8abff7db110d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations_async.py new file mode 100644 index 000000000000..e84ec679d9ac --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-04-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations.py new file mode 100644 index 000000000000..b49d8e2352ee --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations.py @@ -0,0 +1,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_origin_groups_list_by_endpoint(self, resource_group): + response = self.client.origin_groups.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_origin_groups_get(self, resource_group): + response = self.client.origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_origin_groups_begin_create(self, resource_group): + response = self.client.origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "name": "str", + "origins": [{"id": "str"}], + "provisioningState": "str", + "resourceState": "str", + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2025-04-15", + ).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_origin_groups_begin_update(self, resource_group): + response = self.client.origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2025-04-15", + ).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_origin_groups_begin_delete(self, resource_group): + response = self.client.origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.py new file mode 100644 index 000000000000..8112b7d0b50b --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_origin_groups_list_by_endpoint(self, resource_group): + response = self.client.origin_groups.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + 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_origin_groups_get(self, resource_group): + response = await self.client.origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_origin_groups_begin_create(self, resource_group): + response = await ( + await self.client.origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "name": "str", + "origins": [{"id": "str"}], + "provisioningState": "str", + "resourceState": "str", + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_origin_groups_begin_update(self, resource_group): + response = await ( + await self.client.origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2025-04-15", + ) + ).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_origin_groups_begin_delete(self, resource_group): + response = await ( + await self.client.origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py new file mode 100644 index 000000000000..b59ac7f54890 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_origins_list_by_endpoint(self, resource_group): + response = self.client.origins.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_origins_get(self, resource_group): + response = self.client.origins.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_origins_begin_create(self, resource_group): + response = self.client.origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "id": "str", + "name": "str", + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "resourceState": "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", + "weight": 0, + }, + api_version="2025-04-15", + ).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_origins_begin_update(self, resource_group): + response = self.client.origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin_update_properties={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + }, + api_version="2025-04-15", + ).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_origins_begin_delete(self, resource_group): + response = self.client.origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py new file mode 100644 index 000000000000..0e74f3e6b9ef --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_origins_list_by_endpoint(self, resource_group): + response = self.client.origins.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + 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_origins_get(self, resource_group): + response = await self.client.origins.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_origins_begin_create(self, resource_group): + response = await ( + await self.client.origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "id": "str", + "name": "str", + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "resourceState": "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", + "weight": 0, + }, + api_version="2025-04-15", + ) + ).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_origins_begin_update(self, resource_group): + response = await ( + await self.client.origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin_update_properties={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + }, + api_version="2025-04-15", + ) + ).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_origins_begin_delete(self, resource_group): + response = await ( + await self.client.origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py new file mode 100644 index 000000000000..25b13c4f319f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py @@ -0,0 +1,164 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policies_list(self, resource_group): + response = self.client.policies.list( + resource_group_name=resource_group.name, + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policies_get(self, resource_group): + response = self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policies_begin_create_or_update(self, resource_group): + response = self.client.policies.begin_create_or_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy={ + "location": "str", + "sku": {"name": "str"}, + "customRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "enabledState": "str", + } + ] + }, + "endpointLinks": [{"id": "str"}], + "etag": "str", + "extendedProperties": {"str": "str"}, + "id": "str", + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "anomalyScore": 0, + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "rules": [{"ruleId": "str", "action": "str", "enabledState": "str"}], + } + ], + } + ] + }, + "name": "str", + "policySettings": { + "defaultCustomBlockResponseBody": "str", + "defaultCustomBlockResponseStatusCode": 0, + "defaultRedirectUrl": "str", + "enabledState": "str", + "mode": "str", + }, + "provisioningState": "str", + "rateLimitRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "rateLimitDurationInMinutes": 0, + "rateLimitThreshold": 0, + "enabledState": "str", + } + ] + }, + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-04-15", + ).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_policies_begin_update(self, resource_group): + response = self.client.policies.begin_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy_patch_parameters={"tags": {"str": "str"}}, + api_version="2025-04-15", + ).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_policies_delete(self, resource_group): + response = self.client.policies.delete( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations_async.py new file mode 100644 index 000000000000..d4af75a9f66d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations_async.py @@ -0,0 +1,169 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policies_list(self, resource_group): + response = self.client.policies.list( + resource_group_name=resource_group.name, + api_version="2025-04-15", + ) + 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_policies_get(self, resource_group): + response = await self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policies_begin_create_or_update(self, resource_group): + response = await ( + await self.client.policies.begin_create_or_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy={ + "location": "str", + "sku": {"name": "str"}, + "customRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "enabledState": "str", + } + ] + }, + "endpointLinks": [{"id": "str"}], + "etag": "str", + "extendedProperties": {"str": "str"}, + "id": "str", + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "anomalyScore": 0, + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "rules": [{"ruleId": "str", "action": "str", "enabledState": "str"}], + } + ], + } + ] + }, + "name": "str", + "policySettings": { + "defaultCustomBlockResponseBody": "str", + "defaultCustomBlockResponseStatusCode": 0, + "defaultRedirectUrl": "str", + "enabledState": "str", + "mode": "str", + }, + "provisioningState": "str", + "rateLimitRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "rateLimitDurationInMinutes": 0, + "rateLimitThreshold": 0, + "enabledState": "str", + } + ] + }, + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_policies_begin_update(self, resource_group): + response = await ( + await self.client.policies.begin_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy_patch_parameters={"tags": {"str": "str"}}, + api_version="2025-04-15", + ) + ).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_policies_delete(self, resource_group): + response = await self.client.policies.delete( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py new file mode 100644 index 000000000000..ba006716f33b --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py @@ -0,0 +1,257 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_list(self, resource_group): + response = self.client.profiles.list( + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_list_by_resource_group(self, resource_group): + response = self.client.profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_get(self, resource_group): + response = self.client.profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_begin_create(self, resource_group): + response = self.client.profiles.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + profile={ + "location": "str", + "sku": {"name": "str"}, + "extendedProperties": {"str": "str"}, + "frontDoorId": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "name": "str", + "originResponseTimeoutSeconds": 0, + "provisioningState": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-04-15", + ).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_profiles_begin_update(self, resource_group): + response = self.client.profiles.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + profile_update_parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "originResponseTimeoutSeconds": 0, + "tags": {"str": "str"}, + }, + api_version="2025-04-15", + ).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_profiles_begin_delete(self, resource_group): + response = self.client.profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ).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_profiles_begin_can_migrate(self, resource_group): + response = self.client.profiles.begin_can_migrate( + resource_group_name=resource_group.name, + can_migrate_parameters={"classicResourceReference": {"id": "str"}}, + api_version="2025-04-15", + ).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_profiles_begin_migrate(self, resource_group): + response = self.client.profiles.begin_migrate( + resource_group_name=resource_group.name, + migration_parameters={ + "classicResourceReference": {"id": "str"}, + "profileName": "str", + "sku": {"name": "str"}, + "migrationWebApplicationFirewallMappings": [ + {"migratedFrom": {"id": "str"}, "migratedTo": {"id": "str"}} + ], + }, + api_version="2025-04-15", + ).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_profiles_begin_migration_commit(self, resource_group): + response = self.client.profiles.begin_migration_commit( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ).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_profiles_generate_sso_uri(self, resource_group): + response = self.client.profiles.generate_sso_uri( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_list_supported_optimization_types(self, resource_group): + response = self.client.profiles.list_supported_optimization_types( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_list_resource_usage(self, resource_group): + response = self.client.profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_begin_cdn_can_migrate_to_afd(self, resource_group): + response = self.client.profiles.begin_cdn_can_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ).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_profiles_begin_cdn_migrate_to_afd(self, resource_group): + response = self.client.profiles.begin_cdn_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + migration_parameters={ + "sku": {"name": "str"}, + "migrationEndpointMappings": [{"migratedFrom": "str", "migratedTo": "str"}], + }, + api_version="2025-04-15", + ).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_profiles_begin_migration_abort(self, resource_group): + response = self.client.profiles.begin_migration_abort( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations_async.py new file mode 100644 index 000000000000..00f2c4a3e694 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations_async.py @@ -0,0 +1,276 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_profiles_list(self, resource_group): + response = self.client.profiles.list( + api_version="2025-04-15", + ) + 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_profiles_list_by_resource_group(self, resource_group): + response = self.client.profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-04-15", + ) + 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_profiles_get(self, resource_group): + response = await self.client.profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_profiles_begin_create(self, resource_group): + response = await ( + await self.client.profiles.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + profile={ + "location": "str", + "sku": {"name": "str"}, + "extendedProperties": {"str": "str"}, + "frontDoorId": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "name": "str", + "originResponseTimeoutSeconds": 0, + "provisioningState": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_profiles_begin_update(self, resource_group): + response = await ( + await self.client.profiles.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + profile_update_parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "originResponseTimeoutSeconds": 0, + "tags": {"str": "str"}, + }, + api_version="2025-04-15", + ) + ).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_profiles_begin_delete(self, resource_group): + response = await ( + await self.client.profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + ).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_profiles_begin_can_migrate(self, resource_group): + response = await ( + await self.client.profiles.begin_can_migrate( + resource_group_name=resource_group.name, + can_migrate_parameters={"classicResourceReference": {"id": "str"}}, + api_version="2025-04-15", + ) + ).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_profiles_begin_migrate(self, resource_group): + response = await ( + await self.client.profiles.begin_migrate( + resource_group_name=resource_group.name, + migration_parameters={ + "classicResourceReference": {"id": "str"}, + "profileName": "str", + "sku": {"name": "str"}, + "migrationWebApplicationFirewallMappings": [ + {"migratedFrom": {"id": "str"}, "migratedTo": {"id": "str"}} + ], + }, + api_version="2025-04-15", + ) + ).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_profiles_begin_migration_commit(self, resource_group): + response = await ( + await self.client.profiles.begin_migration_commit( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + ).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_profiles_generate_sso_uri(self, resource_group): + response = await self.client.profiles.generate_sso_uri( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_profiles_list_supported_optimization_types(self, resource_group): + response = await self.client.profiles.list_supported_optimization_types( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_profiles_list_resource_usage(self, resource_group): + response = self.client.profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_profiles_begin_cdn_can_migrate_to_afd(self, resource_group): + response = await ( + await self.client.profiles.begin_cdn_can_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + ).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_profiles_begin_cdn_migrate_to_afd(self, resource_group): + response = await ( + await self.client.profiles.begin_cdn_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + migration_parameters={ + "sku": {"name": "str"}, + "migrationEndpointMappings": [{"migratedFrom": "str", "migratedTo": "str"}], + }, + api_version="2025-04-15", + ) + ).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_profiles_begin_migration_abort(self, resource_group): + response = await ( + await self.client.profiles.begin_migration_abort( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations.py new file mode 100644 index 000000000000..57f812ba02ca --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementResourceUsageOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_resource_usage_list(self, resource_group): + response = self.client.resource_usage.list( + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations_async.py new file mode 100644 index 000000000000..a546c7e9e8b8 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementResourceUsageOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_resource_usage_list(self, resource_group): + response = self.client.resource_usage.list( + api_version="2025-04-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations.py new file mode 100644 index 000000000000..45d2a5975966 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRoutesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_routes_list_by_endpoint(self, resource_group): + response = self.client.routes.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_routes_get(self, resource_group): + response = self.client.routes.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_routes_begin_create(self, resource_group): + response = self.client.routes.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "deploymentStatus": "str", + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "id": "str", + "linkToDefaultDomain": "Disabled", + "name": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "provisioningState": "str", + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ).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_routes_begin_update(self, resource_group): + response = self.client.routes.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route_update_properties={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "linkToDefaultDomain": "Disabled", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + }, + api_version="2025-04-15", + ).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_routes_begin_delete(self, resource_group): + response = self.client.routes.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py new file mode 100644 index 000000000000..d550eb0fbacd --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py @@ -0,0 +1,144 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRoutesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_routes_list_by_endpoint(self, resource_group): + response = self.client.routes.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2025-04-15", + ) + 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_routes_get(self, resource_group): + response = await self.client.routes.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_routes_begin_create(self, resource_group): + response = await ( + await self.client.routes.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "deploymentStatus": "str", + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "id": "str", + "linkToDefaultDomain": "Disabled", + "name": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "provisioningState": "str", + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_routes_begin_update(self, resource_group): + response = await ( + await self.client.routes.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route_update_properties={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "linkToDefaultDomain": "Disabled", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + }, + api_version="2025-04-15", + ) + ).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_routes_begin_delete(self, resource_group): + response = await ( + await self.client.routes.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py new file mode 100644 index 000000000000..97c6abaa2881 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRuleSetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rule_sets_list_by_profile(self, resource_group): + response = self.client.rule_sets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rule_sets_get(self, resource_group): + response = self.client.rule_sets.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rule_sets_create(self, resource_group): + response = self.client.rule_sets.create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rule_sets_begin_delete(self, resource_group): + response = self.client.rule_sets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ).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_rule_sets_list_resource_usage(self, resource_group): + response = self.client.rule_sets.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations_async.py new file mode 100644 index 000000000000..cbf5b33c8054 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRuleSetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rule_sets_list_by_profile(self, resource_group): + response = self.client.rule_sets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_rule_sets_get(self, resource_group): + response = await self.client.rule_sets.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rule_sets_create(self, resource_group): + response = await self.client.rule_sets.create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rule_sets_begin_delete(self, resource_group): + response = await ( + await self.client.rule_sets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + ).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_rule_sets_list_resource_usage(self, resource_group): + response = self.client.rule_sets.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations.py new file mode 100644 index 000000000000..45c651135617 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rules_list_by_rule_set(self, resource_group): + response = self.client.rules.list_by_rule_set( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rules_get(self, resource_group): + response = self.client.rules.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rules_begin_create(self, resource_group): + response = self.client.rules.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "deploymentStatus": "str", + "id": "str", + "matchProcessingBehavior": "Continue", + "name": "str", + "order": 0, + "provisioningState": "str", + "ruleSetName": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ).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_rules_begin_update(self, resource_group): + response = self.client.rules.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule_update_properties={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "matchProcessingBehavior": "Continue", + "order": 0, + "ruleSetName": "str", + }, + api_version="2025-04-15", + ).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_rules_begin_delete(self, resource_group): + response = self.client.rules.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py new file mode 100644 index 000000000000..93e22bc6f1e8 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rules_list_by_rule_set(self, resource_group): + response = self.client.rules.list_by_rule_set( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2025-04-15", + ) + 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_rules_get(self, resource_group): + response = await self.client.rules.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rules_begin_create(self, resource_group): + response = await ( + await self.client.rules.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "deploymentStatus": "str", + "id": "str", + "matchProcessingBehavior": "Continue", + "name": "str", + "order": 0, + "provisioningState": "str", + "ruleSetName": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_rules_begin_update(self, resource_group): + response = await ( + await self.client.rules.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule_update_properties={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "matchProcessingBehavior": "Continue", + "order": 0, + "ruleSetName": "str", + }, + api_version="2025-04-15", + ) + ).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_rules_begin_delete(self, resource_group): + response = await ( + await self.client.rules.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py new file mode 100644 index 000000000000..5969143f8d92 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecretsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secrets_list_by_profile(self, resource_group): + response = self.client.secrets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secrets_get(self, resource_group): + response = self.client.secrets.get( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_secrets_begin_create(self, resource_group): + response = self.client.secrets.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + secret={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "secret_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ).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_secrets_begin_delete(self, resource_group): + response = self.client.secrets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py new file mode 100644 index 000000000000..febcd33b8084 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecretsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secrets_list_by_profile(self, resource_group): + response = self.client.secrets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_secrets_get(self, resource_group): + response = await self.client.secrets.get( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_secrets_begin_create(self, resource_group): + response = await ( + await self.client.secrets.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + secret={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "secret_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_secrets_begin_delete(self, resource_group): + response = await ( + await self.client.secrets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py new file mode 100644 index 000000000000..7f50760208d9 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecurityPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_policies_list_by_profile(self, resource_group): + response = self.client.security_policies.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_policies_get(self, resource_group): + response = self.client.security_policies.get( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_security_policies_begin_create(self, resource_group): + response = self.client.security_policies.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "security_policy_properties_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ).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_security_policies_begin_patch(self, resource_group): + response = self.client.security_policies.begin_patch( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy_update_properties={"parameters": "security_policy_properties_parameters"}, + api_version="2025-04-15", + ).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_security_policies_begin_delete(self, resource_group): + response = self.client.security_policies.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2025-04-15", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py new file mode 100644 index 000000000000..3fccd3ad0d6e --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecurityPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_policies_list_by_profile(self, resource_group): + response = self.client.security_policies.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2025-04-15", + ) + 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_security_policies_get(self, resource_group): + response = await self.client.security_policies.get( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2025-04-15", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_security_policies_begin_create(self, resource_group): + response = await ( + await self.client.security_policies.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "security_policy_properties_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-04-15", + ) + ).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_security_policies_begin_patch(self, resource_group): + response = await ( + await self.client.security_policies.begin_patch( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy_update_properties={"parameters": "security_policy_properties_parameters"}, + api_version="2025-04-15", + ) + ).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_security_policies_begin_delete(self, resource_group): + response = await ( + await self.client.security_policies.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2025-04-15", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/setup.py b/sdk/cdn/azure-mgmt-cdn/setup.py index c0f0a3ca2878..4437c35f5ff4 100644 --- a/sdk/cdn/azure-mgmt-cdn/setup.py +++ b/sdk/cdn/azure-mgmt-cdn/setup.py @@ -53,7 +53,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -75,8 +74,9 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.8", + python_requires=">=3.9", )